以上是朋友圈中一奇葩貼:「2月14情人節了,我決定造福你們。第2個贊和第14個讚的,我介紹你倆認識…………咱三吃飯…你倆請…」。現給出此貼下點讚的朋友名單,請你找出那兩位要請客的倒黴蛋。c++
輸入按照點讚的前後順序給出不知道多少個點讚的人名,每一個人名佔一行,爲不超過10個英文字母的非空單詞,以回車結束。一個英文句點.
標誌輸入的結束,這個符號不算在點贊名單裏。spa
根據點贊狀況在一行中輸出結論:若存在第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 ...」。code
GaoXZh Magi Einst Quark LaoLao FatMouse ZhaShen fantacy latesum SenSen QuanQuan whatever whenever Potaty hahaha .
Magi and Potaty are inviting you to dinner...
LaoLao FatMouse whoever .
FatMouse is the only one for you...
LaoLao .
Momo... No one is for you ...
#include<bits/stdc++.h>
using namespace std;
int main()
{
//創建string a[15]
//i++循環
//若i>14,則置爲14
//輸入a[i]
//若輸入a[i]爲 . ,break
//判斷i大小,三狀況
string a[15];
int i = -1;
while(1)
{
i++;
if(i > 14) i = 14;
cin>>a[i];
if(a[i][0] == '.') break;
}
if(i < 2)
cout<<"Momo... No one is for you ...";
else if(i == 14)
cout<<a[1]<<" and "<<a[13]<<" are inviting you to dinner...";
else
cout<<a[1]<<" is the only one for you...";
return 0;
}blog