蒟蒻求助!最后三个点RE
查看原帖
蒟蒻求助!最后三个点RE
155543
Starlight_StationOI楼主2020/6/30 17:18

这题改了好多遍,都是最后三个点RE有大神来帮帮我吗

#include<bits/stdc++.h>
using namespace std;
string a[105],c[105];
int x[105];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		cin>>a[i];
		x[i]=0;
		for(int j=0;j<a[i].length()-2;j++)
		    if(a[i][j]=='s'&&a[i][j+1]=='o'&&a[i][j+2]=='s')
		        x[i]++;
	}
	int max=0;
	for(int i=1;i<=n;i++) if(x[i]>max) max=x[i];
	for(int i=1;i<=n;i++)
	    if(x[i]==max){
	    	cout<<c[i];
	    	cout<<" ";
	    }
	cout<<endl;
	cout<<max;
	return 0;
}

代码有问题吗? 感谢

2020/6/30 17:18
加载中...