以上是朋友圈中一奇葩貼:「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 ...」。內存
輸入樣例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 ...
【代碼】:ci
#include <bits/stdc++.h> using namespace std; int vis[5000]; int main() { int cnt=0; string s,a,b; while(cin>>s) { if(s==".") break; cnt++; //計數器充當數數角色! if(cnt==2) a=s; if(cnt==14) b=s; } if(cnt<=1) cout<<"Momo... No one is for you ..."; else if(cnt>=14) cout<<a<<" and "<<b<<" are inviting you to dinner..."; else cout<<a<<" is the only one for you..."; }