60分求调
查看原帖
60分求调
591287
5_20AM楼主2024/3/17 21:15

求助

5,7,8,9没过

#include<bits/stdc++.h>
using namespace std;
string n,j;
int main(){
	getline(cin,n);
    getline(cin,j);
	n+=' ';
	j+=' ';
 	for(int i=0;n[i];i++) {
        n[i]=tolower(n[i]);
    }
    for(int i=0;j[i];i++) {
        j[i]=tolower(j[i]);
    }
    if(j.find(n)==-1) cout<<"-1"<<endl;
	else{	
		int sum=0;
		int s=0;
		while(j.find(n,s)!=-1){	
			sum++;
			s=j.find(n,s)+1;
		}
		cout<<sum<<" ";
		cout<<j.find(n);
	}
	return 0;
}
2024/3/17 21:15
加载中...