- 谁拿了最多奖学金
- 2018-01-31 15:17:55 @
#include<bits/stdc++.h>
using namespace std;
struct
{
char name[25];
int avg;
int c;
char ganbu;
char shengfen;
int lunwen;
int money=0;
}stu[105];
int main ()
{
int n,i,max=0,p,all=0;
cin>>n;
for (i=1;i<=n;i++)
{
cin>>stu[i].name>>stu[i].avg>>stu[i].c>>stu[i].ganbu>>stu[i].shengfen>>stu[i].lunwen;
if ((stu[i].avg>80)&&(stu[i].lunwen>=1))
stu[i].money=stu[i].money+8000;
if ((stu[i].avg>85)&&(stu[i].c>=80))
stu[i].money=stu[i].money+4000;
if (stu[i].avg>90)
stu[i].money=stu[i].money+2000;
if ((stu[i].avg>85)&&(stu[i].shengfen==89))
stu[i].money=stu[i].money+1000;
if ((stu[i].c>=80)&&(stu[i].ganbu==89))
stu[i].money=stu[i].money+850;
all=all+stu[i].money;
}
for (i=1;i<=n;i++)
{
if (stu[i].money>max)
{
max=stu[i].money;
p=i;
}
}
for (i=1;i<=n;i++)
{
if (stu[i].money==max)
{
p=i;break;
}
}
cout<<stu[p].name<<endl<<stu[p].money<<endl<<all;
}
2 条评论
-
______________ LV 10 @ 2018-02-28 15:40:46
#include<bits/stdc++.h> using namespace std; struct student { char name[100+10]; int all; int banji; char ganbu; char xibu; int lunwen; int money=0; }; struct student a[1000+10],name,all,banji,ganbu,xibu,lunwen; int main() { int n,i,j,t,s; s=0; cin>>n; for(i=1;i<=n;i++) { cin>>a[i].name>>a[i].all>>a[i].banji>>a[i].ganbu>>a[i].xibu>>a[i].lunwen;//输入各项资料 if(a[i].all>80 && a[i].lunwen>=1) a[i].money=a[i].money+8000;//奖项一 if(a[i].all>85 && a[i].banji>80) a[i].money=a[i].money+4000;//奖项二 if(a[i].all>90) a[i].money=a[i].money+2000;//奖项三 if(a[i].all>85 && a[i].xibu=='Y') a[i].money=a[i].money+1000;//奖项四 if(a[i].banji>80 && a[i].ganbu=='Y') a[i].money=a[i].money+850; //奖项五 s=s+a[i].money; } for(i=1;i<=n;i++) for(j=1;j<=n-1;j++) if(a[j].money<a[j+1].money) swap(a[j],a[j+1]);//比较钱数多少(冒泡) for(i=1;i<=1;i++) cout<<a[i].name<<endl<<a[i].money<<endl<<s; return 0; }
-
2018-02-02 12:50:34@
你那个for循环输入可以吗,我的for循环输入也差不多这么写的,但只能输入一次不知道为什么
- 1