L1-070 吃火锅 (15 分)

L1-070 吃火锅 (15 分)

题目连接.
这题写的时候会以为一行有多个给

string s1="chi1 huo3 guo1";

但是在实际操作过程中是不存在这样的,也就是说一行只有一个符合题意的s1;

#include<bits/stdc++.h>
using namespace std;
int main(){
    
    
	string s,s1="chi1 huo3 guo1";
	int find1=0,counter=0,counter1=1,flag=1;
	while(getline(cin,s)&&s!="."){
    
    
		if(s.find(s1)!=-1){
    
    
			if(flag==1){
    
    
				flag=0;
				find1=counter1;
			}
			counter++;
		}
		counter1++;
	}
	if(counter!=0)
	cout<<counter1-1<<endl<<find1<<" "<<counter;
	else cout<<counter1-1<<endl<<"-_-#";
	return 0;
}

猜你喜欢

转载自blog.csdn.net/blastospore/article/details/115416762
今日推荐