| ||||||||||
| 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 | |||||||||
Why WA!!!哪位高手帮忙找找错误.....感激不尽!!#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: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator