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

## 那位高手指点一下,代码哪里有错

Posted by egmna at 2005-09-13 01:35:10 on Problem 2611
```#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int cmp(const void *c,const void *d)
{
return *(char*)c-*(char*)d;
}

int main()
{
char a[50],t;
int i,j,k,l,flag;

while(scanf("%s",a)!=EOF&&strcmp(a,".")!=0)
{
l=strlen(a);
a[l-2]=a[l-1];
l--;
flag=0;
for(i=l-1;i>=0;i--)
{
if(a[i]=='2') {flag=1;a[i]='5';}
else if(a[i]=='6') {flag=1;a[i]='9';}
else for(j=i-1;j>=0;j--)
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
if(a[j]=='5'&&'2'>a[i]) a[j]='2';
if(a[j]=='9'&&'6'>a[i]) a[j]='6';
for(k=j+1;k<=l-1;k++)
if(a[k]=='5') a[k]='2';
else if(a[k]=='9') a[k]='6';
qsort(a+j+1,l-j-1,sizeof(char),cmp);
flag=1;
break;
}
if(flag) break;
}
l++;
a[l-1]=a[l-2];
a[l-2]='.';
if(!flag) printf("The price cannot be raised.\n");
else printf("%s\n",a);
}
}```

Followed by: