为什么这个会是错误?求大神>_<

// input code here
#include <iostream>
#include <string>
using namespace std;
struct student{
    string name;
    int a[3];
    char b[2];
};
int main(){
    int n;
    cout<<"Enter the number of students: "<<endl;
    cin>>n;
    string a;
    student* array=new student[n];
    for (int i=0; i<n; i++) {
        cin>>array[i].name>>array[i].a[0]>>array[i].a[1]>>array[i].b[0]>>array[i].b[1]>>array[i].a[2];
    }
    int index=0;
    int max=0;
    int total=0;
    for (int i=0; i<n; i++) {
        int money=0;
        if ((array[i].a[0]>80)&&(array[i].a[2]>=1)) {
            money+=8000;
        }
        if ((array[i].a[0]>85)&&(array[i].a[1]>80)) {
            money+=4000;
        }
        if (array[i].a[0]>90) {
            money+=2000;
        }
        if ((array[i].a[0]>85)&&(array[i].b[1]=='Y')) {
            money+=1000;
        }
        if ((array[i].a[1]>80)&&(array[i].b[0]=='Y')) {
            money+=850;
        }
        if (money>max) {
            max=money;
            index=i;
        }
        total+=money;
    }
    cout<<array[index].name<<endl;
    cout<<max<<endl;
    cout<<total<<endl;
    
}

1 条评论

  • @ 2017-05-19 20:21:48

    cout<<"Enter the number of students: "<<endl;
    把这个去掉

  • 1

信息

ID
1001
难度
5
分类
模拟 点击显示
标签
递交数
39089
已通过
12717
通过率
33%
被复制
121
上传者