2020-PTA总决赛-L1-6 吃火锅(仅代码)
Code:
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
int msgCnt = 0, pos = -1, cCnt = 0; //msgCnt:消息总条数;pos:第一次出现位置;cCnt:目标信息条数
while(true){
getline(cin, s);
if(s == ".") break;
msgCnt++;
if(s.find("chi1 huo3 guo1") != -1){
if(pos == -1) pos = msgCnt;
cCnt++;
}
}
cout << msgCnt << endl;
if(cCnt == 0){
cout << "-_-#" << endl;
}else{
cout << pos << ' ' << cCnt << endl;
}
return 0;
}