L1-035. 情人节
以上是朋友圈中一奇葩贴:“2月14情人节了,我决定造福大家。第2个赞和第14个赞的,我介绍你俩认识…………咱三吃饭…你俩请…”。现给出此贴下点赞的朋友名单,请你找出那两位要请客的倒霉蛋。
输入格式:
输入按照点赞的先后顺序给出不知道多少个点赞的人名,每个人名占一行,为不超过10个英文字母的非空单词,以回车结束。一个英文句点“.”标志输入的结束,这个符号不算在点赞名单里。
输出格式:
根据点赞情况在一行中输出结论:若存在第2个人A和第14个人B,则输出“A and B are inviting you to dinner...”;若只有A没有B,则输出“A is the only one for you...”;若连A都没有,则输出“Momo... No one is for you ...”。
输入样例1:GaoXZhMagiEinstQuarkLaoLaoFatMouseZhaShenfantacylatesumSenSenQuanQuanwhateverwheneverPotatyhahaha.输出样例1:
Magi and Potaty are inviting you to dinner...输入样例2:
LaoLaoFatMousewhoever.输出样例2:
FatMouse is the only one for you...输入样例3:
LaoLao.输出样例3:
Momo... No one is for you ...
1 #include2 using namespace std; 3 typedef long long LL; 4 const int maxn = 100010; 5 int main() { 6 string s; 7 int i = 0; 8 string a, b; 9 int flag0 = 0, flag1 = 0;10 while (cin >> s) {11 if (s == ".")12 break;13 i += 1;14 if (i == 2) {15 flag0 = 1;16 a = s;17 }18 if (i == 14) {19 b = s;20 flag1 = 1;21 }22 }23 if (flag0 == 0 && flag1 == 0) {24 printf ("Momo... No one is for you ...\n");25 } else if (flag0 == 1 && flag1 == 0) {26 cout << a;27 printf (" is the only one for you...\n");28 } else {29 cout << a << " and " << b;30 printf (" are inviting you to dinner...\n");31 }32 return 0;33 }