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

## Why WA!!!哪位高手帮忙找找错误.....感激不尽！！

Posted by yuech at 2009-06-03 02:18:23 on Problem 2051
```#include<stdio.h>
#include<string.h>
struct regester
{
char str[20];
int ID;
int t;
int tsum;
};
int main()
{
int temp,i,j,h,p,k,a[1000],t,b,s;
struct regester test[1001];
i=0;
while(scanf("%s",test[i].str),strcmp(test[i].str,"#")!=0)
{
scanf("%d %d",&test[i].ID,&test[i].t);
test[i].tsum=test[i].t;
a[i]=0;
i++;
}
scanf("%d",&k);
p=0;
while(p<k)
{
h=0;
for(j=1;j<i;j++)
if(test[j].tsum<test[h].tsum)
h=j;
a[0]=test[h].ID;
s=1;
test[h].tsum=test[h].tsum+test[h].t;
for(j=h+1;j<i;j++)
if(test[j].tsum==test[h].tsum-test[h].t)
{
a[s]=test[j].ID;
s++;
test[j].tsum=test[j].tsum+test[j].t;
}
b=0;
for(j=0;j<s;j++)
{
b=j;
for(t=j+1;t<s;t++)
if(a[t]<a[b])
b=t;
printf("%d\n",a[b]);
temp=a[t];
a[t]=a[j];
a[j]=temp;
p++;
if(p>=k)
break;
}

}
}
```

Followed by: