cin 和 string 的灵异事件
  • 板块学术版
  • 楼主helpcyg
  • 当前回复5
  • 已保存回复5
  • 发布时间2021/1/29 20:41
  • 上次更新2023/11/5 04:11:04
查看原帖
cin 和 string 的灵异事件
327288
helpcyg楼主2021/1/29 20:41

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,也报错

求助啊

2021/1/29 20:41
加载中...