團體程序設計天梯賽-練習集-L1-035. 情人節

L1-035. 情人節

以上是朋友圈中一奇葩貼:「2月14情人節了,我決定造福你們。第2個贊和第14個讚的,我介紹你倆認識…………咱三吃飯…你倆請…」。現給出此貼下點讚的朋友名單,請你找出那兩位要請客的倒黴蛋。c++

輸入格式:spa

輸入按照點讚的前後順序給出不知道多少個點讚的人名,每一個人名佔一行,爲不超過10個英文字母的非空單詞,以回車結束。一個英文句點「.」標誌輸入的結束,這個符號不算在點贊名單裏。code

輸出格式:blog

根據點贊狀況在一行中輸出結論:若存在第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 ...」。ci

輸入樣例1:
GaoXZh
Magi
Einst
Quark
LaoLao
FatMouse
ZhaShen
fantacy
latesum
SenSen
QuanQuan
whatever
whenever
Potaty
hahaha
.
輸出樣例1:
Magi and Potaty are inviting you to dinner...
輸入樣例2:
LaoLao
FatMouse
whoever
.
輸出樣例2:
FatMouse is the only one for you...
輸入樣例3:
LaoLao
.
輸出樣例3:
Momo... No one is for you ...

 

 1 #include<bits/stdc++.h>
 2 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 }
相關文章
相關標籤/搜索