新手入门,想用这个题目把最近学的都用上,所以代码比较多,欢迎各位大神指正

//以下代码通过了测试
#include<iostream>;
using namespace std;
#include<string>;
#include<cstdlib>;
#define MAX 100

struct student
{
string name;
int score1;
int score2;
string ad;
string area;
int essay;
int money = 0;
};

struct stubook
{
struct student stuarr[MAX];

int N;
};

void sure(struct stubook *stuarr)
{
for (int i = 0; i < stuarr->N; i++)
{
if (stuarr->stuarr[i].score1 > 80 && stuarr->stuarr[i].essay >= 1)
{
stuarr->stuarr[i].money += 8000;
}
if (stuarr->stuarr[i].score1 > 85 && stuarr->stuarr[i].score2 > 80)
{
stuarr->stuarr[i].money += 4000;
}
if (stuarr->stuarr[i].score1 > 90)
{
stuarr->stuarr[i].money += 2000;
}
if (stuarr->stuarr[i].score1 > 85 && stuarr->stuarr[i].area == "Y")
{
stuarr->stuarr[i].money += 1000;
}
if (stuarr->stuarr[i].score2 > 80 && stuarr->stuarr[i].ad == "Y")
{
stuarr->stuarr[i].money += 850;
}
}

}

int main()
{
struct stubook stuarr;

cin >> stuarr.N;

for (int i = 0; i < stuarr.N; i++)
{
cin >> stuarr.stuarr[i].name >> stuarr.stuarr[i].score1 >> stuarr.stuarr[i].score2
>> stuarr.stuarr[i].ad >> stuarr.stuarr[i].area >> stuarr.stuarr[i].essay;
}

sure(&stuarr);

int maxmoney = 0;

for (int i = 0; i < stuarr.N ; i++)
{
maxmoney = (maxmoney > stuarr.stuarr[i].money ? maxmoney : stuarr.stuarr[i].money);
}

string maxname;

for (int i = 0; i < stuarr.N; i++)
{
if (maxmoney == stuarr.stuarr[i].money)
{
maxname = stuarr.stuarr[i].name;
break;
}
}

int sum = 0;

for (int i = 0; i < stuarr.N; i++)
{
sum += stuarr.stuarr[i].money;
}

cout << maxname << endl;
cout << maxmoney << endl;
cout << sum << endl;

system("pause");

return 0;
}

3 条评论

  • @ 2022-08-30 10:59:42

    你看起来像个神经病捏,还在用这没人管的危较寺,跟我一起摧毁这个网站

  • @ 2022-08-28 21:11:03

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    int c;
    cin>>c;
    string name[c];
    char n,m;
    int x,y,z,money[c],max_money=0,s_money=0;
    memset(money,0,sizeof(money));
    for(int i=0;i<c;i++)
    {
    cin>>name[i]>>x>>y>>n>>m>>z;
    if(x>80&&z>=1)money[i]+=8000;
    if(x>85&&y>80)money[i]+=4000;
    if(x>90)money[i]+=2000;
    if(x>85&&m=='Y')money[i]+=1000;
    if(y>80&&n=='Y')money[i]+=850;
    if(money[i]>max_money)
    max_money=money[i];
    s_money+=money[i];
    }
    for(int i=0;i<c;i++)
    if(max_money==money[i])
    {
    cout<<name[i]<<endl<<max_money<<endl<<s_money<<endl;
    break;
    }
    return 0;
    }

  • @ 2021-10-08 18:53:39

    伞兵吧

  • 1

信息

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