求助,本地编译没错,但提交后说编译错误。
查看原帖
求助,本地编译没错,但提交后说编译错误。
1044704
M_asdfghjkl楼主2023/7/28 14:46
#include <iostream>
#include <string>
using namespace std;

string s1,s2;
int first,next,a;

int main()
{
	getline(cin,s1);
	getline(cin,s2); 
	for(int i=0;i<s1.length() ;i++){
		if(s1[i]>='A'&&s1[i]<='Z'){
			s1[i]=s1[i]-'A'+'a';
		}
	}
	for(int i=0;i<s2.length() ;i++){
		if(s2[i]>='A'&&s2[i]<='Z'){
			s2[i]=s2[i]-'A'+'a';
		}
	}
	s1=' '+s1+' ';
	s2=' '+s2+' ';
	if(s2.find(s1)==-1){
		cout<<"-1";
	}else{
		first=s2.find(s1);
		next=s2.find(s1);
		while(next!=-1) {
			a++;
			next=s2.find(s1,next+1);
		}
		cout<<a<<" "<<first;
	}
	return 0;
} 
2023/7/28 14:46
加载中...