WHY IS THE ERROR?
查看原帖
WHY IS THE ERROR?
1101201
Wang_xin_chen楼主2024/7/5 21:59

Please help me. Thanks!

#include<bits/stdc++.h>
using namespace std;
int n;
bool cmp(f a,f b){
	return a.num>b.num;
}
struct f{
    string name,sos;
    int num;
}a[115];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>a[i].name>>a[i].sos;
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<a[i].sos.size();j++){	
			if(a[i].sos[j]=='o' && a[i].sos[j-1]=='s' && a[i].sos[j+1]=='s') a[i].num++;	
		}
	}
	sort(a+1,a+n+1,cmp);
	cout<<a[i].name<<endl<<a[i].num;
    return 0;
}

The error is 'f' was not declared in this scope on 4 .

2024/7/5 21:59
加载中...