题目解析
输入一些字符串 看其有多少个 在按指定格式输出
解题思路
用n统计人数 A,B 来存储 “倒霉蛋”
看AB是否都有"倒霉蛋"
然后按格式输出最后的答案
代码
import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[] args)
{
String A = "", B = "";
int n = 0;
while (sc.hasNext())
{
n++;
String s = sc.next();
if (s.equals("."))
break;
if (n == 2)
A = s;
else if (n == 14)
B = s;
}
if (!B.equals(""))
out.printf("%s and %s are inviting you to dinner...", A, B);
else if (!A.equals(""))
out.printf("%s is the only one for you...", A);
else
out.printf("Momo... No one is for you ...");
out.flush();
out.close();
}
static Scanner sc = new Scanner(System.in);
static PrintWriter out = new PrintWriter(System.out);
}