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

## 为什么WA，哪位高手帮帮忙

Posted by 283893051 at 2009-04-14 22:02:14 on Problem 2611
```#include<stdio.h>
#include<string.h>
int main(void)
{
char price[30];
int len;
int i;
int j;
int t;
int flag;
int sum;
while(scanf("%s",&price)!=EOF)
{
len=strlen(price);
flag=0;
sum=0;
for(i=0;i<len;i++)
{
if(price[i]=='.')sum++;
}
if((price[0]=='0'&&price[1]!='.')||price[len-1]=='.')printf("Input error\n");
else if(sum>1)printf("Input error\n");
else
{
for(i=len-1;i>0;i--)
{
if(price[i]=='6')
{
flag=1;
price[i]='9';
break;
}
else if(price[i]=='2')
{
flag=1;
price[i]='5';
break;
}
else
{
for(j=i-1;j>0;j--)
{
if(price[j]=='.')
{
j--;
if(price[i]>price[j])
{
flag=1;
t=price[i];
price[i]=price[j];
price[j]=t;
}
break;
}
if(price[i]>price[j])
{
flag=1;
t=price[i];
price[i]=price[j];
price[j]=t;
break;
}
}
}
}
if(flag==0)
printf("The price cannot be raised.\n");
if(flag==1)
printf("%s\n",price);
}
}
return 0;
}
```

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator