Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

请问这个程序有什么问题啊,为什么会WA的?

Posted by 200630690119 at 2008-07-17 20:06:10 on Problem 2218
#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,&pound);
				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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator