在visual studio编译没错怎么在这编译就错误了

#include<iostream>
#include<string>
using namespace std;
#define M 100

int prize_sum(int fin_score, int class_score, string isnorth, string iscadre,int dis_count)
{
int sum=0;
if (fin_score > 80 && dis_count >= 1)
{
sum+= 8000;
}
if (fin_score > 85 && class_score >= 80)
{
sum += 4000;
}
if (fin_score > 90)
{
sum += 2000;
}
if (fin_score > 85 && isnorth == "Y")
{
sum += 1000;
}
if (class_score > 80 && iscadre == "Y")
{
sum += 850;
}
return sum;
}

int main()
{
struct Array {
string name;
int fin_score;
int class_score;
string iscadre;
string isnorth;
int dis_count;
int sum;
};

int student_num;
cin >> student_num;

struct Array a[M];
for (int i = 0; i < student_num; i++)
{
cin >> a[i].name >> a[i].fin_score >> a[i].class_score >> a[i].iscadre >> a[i].isnorth >> a[i].dis_count;
a[i].sum = prize_sum(a[i].fin_score, a[i].class_score, a[i].isnorth, a[i].iscadre, a[i].dis_count);
}
for (int i = 0; i < student_num-1; i++)
{
for (int j = 0; j < student_num - i - 1; j++)
{
Array temp;
if (a[j].sum < a[j + 1].sum)
{
temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
}
cout << a[0].name<<endl;
cout << a[0].sum<<endl;
int cou = 0;
for (int i = 0; i < student_num; i++)
{

cou += a[i].sum;
}
cout << cou << endl;
}

3 条评论

  • @ 2021-08-12 21:46:14

    我的好了,正确的

  • @ 2021-08-12 21:44:57

    我的状态是Fetched

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long L;
    L b,c,f,n,m,r,s;
    string a,g;
    char d,e;
    int main()
    {
        scanf("%lld",&n);
        for(L i=1;i<=n;i++)
        {
            cin>>a;
            scanf("%lld%lld",&b,&c);
            cin>>d>>e;
            scanf("%lld",&f);
            m=0;
            if(b>80&&f>=1)
            m+=8000;
            if(b>85&&c>80)
            m+=4000;
            if(b>90)
            m+=2000;
            if(b>85&&e=='Y')
            m+=1000;
            if(c>80&&d=='Y')
            m+=850;
            s+=m;
            if(r<m)
            {
                r=m;
                g=a;
            }
        }
        cout<<g<<"\n";
        printf("%lld\n%lld",r,s);
        return 0;
    }
    
    
  • @ 2021-08-10 21:41:22

    编译没问题啊,但代码写错了

  • 1

信息

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