| ||||||||||
| 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 | |||||||||
怎么执行后会退出?????(有CODE)无语了 ~~~~~~#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char temp1[10];
int num;
struct peo
{
char name[30];
int days;
int weight;
}people[150];
int comp(const void* a,const void *b)
{
struct peo *x=(struct peo*)a;
struct peo *y=(struct peo*)b;
return( ( (y->weight)>(x->weight) )?1:-1);
}
void solve(void)
{
int i;
num=1;
strcpy(temp1,"");
while((scanf("%s",temp1))==1)
{
if(strcmp(temp1,"END")!=0)
{
strcpy(people[num].name,temp1);
strcpy(temp1,"");
scanf("%d",people[num].days);
scanf("%d",people[num].weight);
num++;
}
else
{
break;
}
}
for(i=1;i<num;i++)
{
people[i].weight=people[i].weight-people[i].days;
}
qsort(&people[1],num-1,sizeof(people[0]),comp);
for(i=1;i<num;i++)
{
printf("%s\n",people[i].name);
}
printf("\n");
}
int main()
{
for(;;)
{
scanf("%s",temp1);
if(strcmp(temp1,"START")==0)
{
strcpy(temp1,"");
solve();
}
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator