**
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...");
}
}
}
这是一个关于情人节的编程题目,通过判断输入的行数来决定输出不同的情人节祝福信息。当输入行数小于等于1时,输出Momo...No one is for you...;当输入行数大于1且小于13时,输出第一行字符串加is the only one for you...;当输入行数大于等于13时,输出第一行和第十三行字符串加are inviting you to dinner...。
660

被折叠的 条评论
为什么被折叠?



