- 谁拿了最多奖学金
- 2016-07-30 00:33:31 @
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{
int max=-1,count=0,p=0,k=0,t,r=0,i,j,n;
int ml[101]={0},mc[101]={0},ar[101]={0},sum[101]={0};
char ch;
char name[101][101];
char mo[101],ws[101];
memset(name,0,sizeof(name));
memset(mo,0,sizeof(mo));
memset(ws,0,sizeof(ws));
scanf("%d\n",&n);
for(i=1;i<=n;i++)
{
while(scanf("%c",&ch)!=EOF&&ch!='\0'&&isalpha(ch))
{
k++;
name[i][k]=ch;
}
for(j=1;j<=2;j++)
{
scanf("%d ",&t);
p++;
if(p==1)
ml[i]=t;
if(p==2)
mc[i]=t;
}
for(j=1;j<=2;j++)
{
scanf("%c ",&ch);
r++;
if(r==1)
mo[i]=ch;
if(r==2)
ws[i]=ch;
}
r=0;p=0;k=0;
scanf("%d\n",&ar[i]);
}//读入数据
for(i=1;i<=n;i++)
{
if(ml[i]>80&&ar[i]>=1)
sum[i]+=8000;
if(ml[i]>85&&mc[i]>80)
sum[i]+=4000;
if(ml[i]>90)
sum[i]+=2000;
if(ml[i]>80&&ws[i]=='Y')
sum[i]+=1000;
if(mc[i]>80&&mo[i]=='Y')
sum[i]+=850;
}//判断奖学金
for(i=1;i<=n;i++)
{
count+=sum[i];
if(max<sum[i])
{
max=sum[i];
k=i;
}
}//找出最大
j=1;
while(name[k][j]!='\0')
{
printf("%c",name[k][j]);
j++;
}
printf("\n");
printf("%d\n",max);
printf("%d ",count);
return 0;
}
3 条评论
-
唐复之 LV 8 @ 2016-07-31 11:11:06
请使用语法高亮,不然读者看起来会非常吃力
-
2016-07-31 11:10:02@
#include<stdio.h> #include<string.h> #include<iostream> using namespace std; long long n,total=0; int q; struct { char s[21]; int fen,Class,ganbu,xibu,lunwen; long monny; }xyz[101]; void putin() { int i; scanf("%lld",&n); for(i=1;i<=n;i++){ char a1,b1; scanf("%s %d %d %c %c %d",&xyz[i].s,&xyz[i].fen,&xyz[i].Class,&a1,&b1,&xyz[i].lunwen); if(a1=='Y') xyz[i].ganbu=1; else xyz[i].ganbu=0; if(b1=='Y') xyz[i].xibu=1; else xyz[i].xibu=0; } } void work() { int i; for(i=1;i<=n;i++) xyz[i].monny=0; for(i=1;i<=n;i++){ if(xyz[i].fen>80 && xyz[i].lunwen>=1) xyz[i].monny+=8000; if(xyz[i].fen>85 && xyz[i].Class>80) xyz[i].monny+=4000; if(xyz[i].fen>90) xyz[i].monny+=2000; if(xyz[i].fen>85 && xyz[i].xibu==1) xyz[i].monny+=1000; if(xyz[i].Class>80 && xyz[i].ganbu==1) xyz[i].monny+=850; total+=xyz[i].monny; } } void work2() { long Max=0; int i; for(i=1;i<=n;i++) if(xyz[i].monny>Max){ q=i; Max=xyz[i].monny; } } void putout() { printf("%s\n",&xyz[q].s); cout<<xyz[q].monny<<"\n"; cout<<total; } int main() { putin(); work(); work2(); putout(); return 0; }
一道很水的题
-
2016-07-31 11:09:57@
#include<stdio.h> #include<string.h> #include<iostream> using namespace std; long long n,total=0; int q; struct { char s[21]; int fen,Class,ganbu,xibu,lunwen; long monny; }xyz[101]; void putin() { int i; scanf("%lld",&n); for(i=1;i<=n;i++){ char a1,b1; scanf("%s %d %d %c %c %d",&xyz[i].s,&xyz[i].fen,&xyz[i].Class,&a1,&b1,&xyz[i].lunwen); if(a1=='Y') xyz[i].ganbu=1; else xyz[i].ganbu=0; if(b1=='Y') xyz[i].xibu=1; else xyz[i].xibu=0; } } void work() { int i; for(i=1;i<=n;i++) xyz[i].monny=0; for(i=1;i<=n;i++){ if(xyz[i].fen>80 && xyz[i].lunwen>=1) xyz[i].monny+=8000; if(xyz[i].fen>85 && xyz[i].Class>80) xyz[i].monny+=4000; if(xyz[i].fen>90) xyz[i].monny+=2000; if(xyz[i].fen>85 && xyz[i].xibu==1) xyz[i].monny+=1000; if(xyz[i].Class>80 && xyz[i].ganbu==1) xyz[i].monny+=850; total+=xyz[i].monny; } } void work2() { long Max=0; int i; for(i=1;i<=n;i++) if(xyz[i].monny>Max){ q=i; Max=xyz[i].monny; } } void putout() { printf("%s\n",&xyz[q].s); cout<<xyz[q].monny<<"\n"; cout<<total; } int main() { putin(); work(); work2(); putout(); return 0; }
一道很水的题
- 1