L1-035 情人節 (15 分)

以上是朋友圈中一奇葩貼:“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:

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 ...

源碼: 

#include<string>
#include<iostream>
using namespace std;

int main(){
	string s, a, b;
	int count = 1;
	cin>>s;
	while(s.find(".") == string::npos){
		cin>>s;
		if(s.find(".") != string::npos) break;
		count++;
		if(count == 2)		 a = s;
		else if(count == 14) b = s;
	}
	if(count < 2)		cout<<"Momo... No one is for you ...";
	else if(count <14)	cout<<a<<" is the only one for you...";
	else 				cout<<a<<" and "<<b<<" are inviting you to dinner...";
	return 0;
} 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章