杭电的acm1106 一直都是wa。。求高手

2024-12-17 01:57:09
推荐回答(1个)
回答1:

#include
#define m 10000
int main()
{
int p[m],i,j,k,n;
char a[m];
while(1)
{
i=0;n=0,k=0;
while((a[i]=getchar())!='\n'&&a[i]!=EOF)
i++;
if(a[i]==EOF) break;
for(j=0;j if(a[j]!='5')
k=k*10+a[j]-'0';
else if(a[j+1]!='5')
{
p[n]=k;
k=0;
n++;
}
if(a[i-1]!='5')
{
p[n]=k;
n=n+1;
}
for(j=0;j for(i=0;i if(p[i]>p[i+1])
{
k=p[i];
p[i]=p[i+1];
p[i+1]=k;
}
/*if(a[0]!='5')
printf("%d ",p[0]);
for(j=1;j printf("%d ",p[j]);
printf("%d\n",p[n-1]);
*/
if(a[0]!='5') j=0;
else j=1;
printf("%d",p[j++]);
for(;j printf(" %d",p[j]);
printf("\n");
}

}