Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
C111的代码,高手们帮我简化一下#include<stdio.h> int main() { int i,j,maxd,mine; int d[4]={0,0,0,0}; int e[4]={0,0,0,0}; typedef struct ppp { char a[4][20]; int b[4][4]; int c[4][4]; }pp; pp p; scanf("%d",&i); for(i=0;i<4;i++) { scanf("%s",p.a[i]); scanf("%d",&p.b[i][0]); scanf("%d",&p.c[i][0]); scanf("%d",&p.b[i][1]); scanf("%d",&p.c[i][1]); scanf("%d",&p.b[i][2]); scanf("%d",&p.c[i][2]); scanf("%d",&p.b[i][3]); scanf("%d",&p.c[i][3]); } for(i=0;i<4;i++) { for(j=0;j<4;j++) { if(p.c[i][j]>0) { d[i]++; e[i]=e[i]+(p.b[i][j]-1)*20+p.c[i][j]; } } } maxd=d[0]; mine=e[0]; for(i=0;i<4;i++) { if(maxd<d[i]) { maxd=d[i]; mine=e[i]; } if(maxd==d[i]&&e[i]<mine) { maxd=d[i]; mine=e[i]; } } for(i=0;i<4;i++) { if(d[i]==maxd&&e[i]==mine) { printf("%s %d %d\n",p.a[i],d[i],e[i]); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator