1 4 YaoLin 87 82 Y N 0 ChenRuiyi 88 78 N Y 1 LiXin 92 88 N N 0 ZhangQin 83 87 Y N 1
<pre class="cpp" name="code">#include<iostream> #include<stdio.h> #include<string> #include<string.h> using namespace std ; int main() { int i,j,n,m,pj,py,t,s,max,sum; char gb,xb; string name1,name; scanf("%d",&m); getchar(); for(i=0;i<m;i++) { scanf("%d",&n); max=0; sum=0; for(j=0;j<n;j++) { getchar(); s=0; cin >> name ;//此处不能用scanf("%s",&n); scanf("%d %d %c %c %d",&pj,&py,&gb,&xb,&t); if(pj>80&&t>=1) s+=8000; if(pj>85&&py>80) s+=4000; if(pj>90) s+=2000; if(pj>85&&xb=='Y') s+=1000; if(py>80&&gb=='Y') s+=850; if(s>max) { max=s; name1=name; } sum+=s; } cout << name1 << endl ;//此处不能用printf("%s\n",name1); printf("%d\n",max); printf("%d\n",sum); } return 0; }
//C语言
#include<stdio.h> #include<string.h> int main() { int i,j,n,m,pj,py,t,s,max,sum; char gb,xb; char name1[20],name[20]; scanf("%d",&m); getchar(); for(i=0;i<m;i++) { scanf("%d",&n); max=0; sum=0; for(j=0;j<n;j++) { getchar(); s=0; scanf("%s",&name); scanf("%d %d %c %c %d",&pj,&py,&gb,&xb,&t); if(pj>80&&t>=1) s+=8000; if(pj>85&&py>80) s+=4000; if(pj>90) s+=2000; if(pj>85&&xb=='Y') s+=1000; if(py>80&&gb=='Y') s+=850; if(s>max) { max=s; strcpy(name1,name); } sum+=s; } printf("%s\n",name1); printf("%d\n",max); printf("%d\n",sum); } return 0; }
原文:http://blog.csdn.net/phytn/article/details/38271615