P1051
代码:
#include<bits/stdc++.h>
struct student{
string name;
int test,chat;
char gb,west;
int paper;
int all;
}stu[105];
bool cmp(student a,student b){
return a.all > b.all;
}
int main(){
int n;
cin>>n;
int every = 0;
for(int i = 0;i < n;i++){
cin>>stu[i].name>>stu[i].test>>stu[i].chat>>stu[i].gb>>stu[i].west>>stu[i].paper;
if(stu[i].test > 80 && stu[i].paper >= 1) stu[i].all += 8000;
if(stu[i].test > 85 && stu[i].chat > 80) stu[i].all += 4000;
if(stu[i].test > 90) stu[i].all += 2000;
if(stu[i].test > 85 && stu[i].west == 'Y') stu[i].all += 1000;
if(stu[i].chat > 80 && stu[i].gb == 'Y') stu[i].all += 850;
every += stu[i].all;
}
sort(stu,cmp);
cout<<stu[0].name<<endl<<stu[0].all<<endl<<every;
return 0;
}
报错信息里说:
string’ does not name a type
and
‘cin’在此作用域中尚未声明
我用了万能头。
也试过iostream,也报错
求助啊