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 |
为什么WA?#include <stdio.h> #include <stdlib.h> #include <string.h> struct student{ int a; int b; }sort[100000]; int cmp(const void *a,const void *b) { struct student *c=(student *)a; struct student *d=(student *)b; if(c->a==d->a) return d->b-c->b; return d->a-c->a; } int main() { char *message="Li Ming"; int i,j,l,m,n,v; char str[1000];char c; scanf("%d",&n); scanf("%c",&c); for(i=0;i<n;i++) gets(str); scanf("%d",&m); scanf("%c",&c); for(l=0;l<m;l++) { for(i=0;i<n;i++){ gets(str); for(sort[i].b=0,j=0;str[j];j++) if(str[j]==' '){ if(strcmp(str+j+1,message)==0) sort[i].b=1; break; } sscanf(str,"%d",&v); if(!l) sort[i].a=v; else if(l) sort[i].a+=v; } qsort(sort,n,sizeof(sort[0]),cmp); for(i=0;i<n;i++) if(sort[i].b){ printf("%d\n",i+1); break; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator