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

Discussion of Problem 1354. Palindrome. Again Palindrome

please help !! !! !! !! !!
Posted by I_want_to_be_The_Best 28 Apr 2005 23:57
please help !! !! !! !! !!
Posted by I_want_to_be_The_Best 28 Apr 2005 23:59
why my program not work ??
#include<iostream.h>
//#include<conio.h>
//
char s[10001];
char s2[10001];
char s3[20002];
int l;
//-------------------------------------
int L(void);
int Pal(int i);
int First(void);
//-------------------------------------
void main(void)
{
 //clrscr();
 //
 int x,i;
 //
 cin>>s;
 //
 l=L();
 x=First();
 //
 //printf("%s",s);
 for(i=x-1;i>=0;i--)
    s2[x-1-i]=s[i];
 s2[x]=0;
 for(i=0;i<x;i++)
    s[l+i]=s2[i];
 s[l+x]=0;
 for(i=0;s[i];i++)
    s3[i]=s[i];
 cout<<s3;
 //
 //getch();
}
//-------------------------------------
int L(void)
{
 int r;
 //
 for(r=0;s[r];r++);
 //
 return(r);
}
//
int First(void)
{
 int r,flag=1;
 //
 r=1;
 while((flag)&&(r<l))
      if(Pal(r))
    flag=0;
      else
      r++;
 //
 return(r);
}
//
int Pal(int i)
{
 int r;
 //
 while((r)&&( r<((l+i)/2) ))
      if(s[r]==s[l-r+i-1])
    r++;
      else
      r=0;
 //
 return(r);
}


i not see error !! !!
Re: please help !! !! !! !! !!
Posted by YoD 10 May 2005 18:09
On test:

vxabba

your program outputs  vxabbaabbaxv, but right answer is vxabbaxv
Re: please help !! !! !! !! !!
Posted by cold_Iron 13 May 2005 22:20
thanks for the test!
i fixed the bug, but I still WA#4