ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

where're my bugs? help me please=>problem 1123
Posted by TheBlaNK 21 Dec 2001 22:25
this is my program
=>
#include <stdio.h>
#include <string.h>
int main()
{
 int state,pos,i,n,len,reach=0;
 char str[2005],a;
 scanf("%s",str);
 len=strlen(str);
 n=len/2;
 for(i=0,state=0;i<n;i++)
 {
   if(str[i]!=str[len-i-1])
    {if(state==1) { str[pos]=a; state=0; reach=1; }
     a=str[i];
     pos=len-i-1;
     state=1;
    }
 }
 if(!reach) if(str[pos]>str[len-pos-1]) { str[len-pos-1]++; str[pos]=str
[len-pos-1];  }
        else str[pos]=str[len-pos-1];
 else
  {
   if(str[len-pos-1]>str[pos]) { str[pos]=str[len-pos-1]; }
   else { str[len-pos-1]++; str[pos]=str[len-pos-1]; }
  }
 printf("%s",str);
 return 0;
}
Looks like you do not handle if 9s appear in the middle.
Posted by Timus Observer 22 Dec 2001 06:21
You should increase (+1) the digit before the 9s then change the 9s
with 0s.
Re: Looks like you do not handle if 9s appear in the middle.
Posted by TheBlaNK 22 Dec 2001 16:46
oh
Thank you very much