| ||||||||||
| 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"string.h"
#include"stdlib.h"
struct d{
char name[40];
int weight;
}dieter[200];
int comp(const void*a,const void*b){
struct d* x=(struct d*)a;
struct d* y=(struct d*)b;
return (x->weight<y->weight);
}
void main(){
char start[]={"START"},end[]="END";
char s[20];
int i,day,pound,len,count=200;
while(count>0){
scanf("%s",s);
if(strcmp(s,start)==0){
i=0;
scanf("%s",s);
while(strcmp(s,end)!=0){
scanf("%d%d",&day,£);
dieter[i].weight=pound-day;
strcpy(dieter[i].name,s);
i++;
scanf("%s",s);
}
}
len=i;
qsort(&dieter[0],len,sizeof(dieter[0]),comp);
for(i=0;i<len;i++)
printf("%s\n",dieter[i].name);
printf("\n");
count--;
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator