PTA JAVA L1-035 情人节 (15 分)

**

L1-035 情人节 (15 分)

**



import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str [] =new String [2];
        int n=0;
        while(sc.hasNext()) {
        	String s =sc.nextLine();
        	if(s.equals(".")) {
        		break;
        	}
        	if(n==1) {
        		str[0]=s;
        	}
        	if(n==13) {
        		str[1]=s;
        	}
        	n++;
        }
        if(n<=1) {
        	System.out.println("Momo... No one is for you ...");
        }
        if(n>1&&n<13) {
        	System.out.println(str[0]+" is the only one for you...");
        }
        if(n>=13) {
        	System.out.println(str[0]+" and "+ str[1]+" are inviting you to dinner...");
        }
    }
}

你可能感兴趣的:(java)