poate cineva sa ma ajute
iau 0 cu solutia
#include <fstream>
#define nmax 20001
using namespace std;
ifstream fi("palindrom2.in");
ofstream fo("palindrom2.out");
char s[nmax];
int corespunde(int p)
{
for (int i=1;i<=(p+1)/2;++i)
if (s!=s[p-i+1])
return 1;
return 0;
}
int main(void)
{
int n=0;
while (!fi.eof())
{
++n;
fi.get(s[n]);
if (s[n]=='\n')
--n;
}
int ok=1;
int i;
int p=n;
if (n%2)
--p;
if (corespunde(n))
for (i=1;i<=p && ok;++i)
{
for (int j=i;j>0;--j)
s[n+j]=s[i-j+1];
ok=corespunde(n+i);
}
n+=i;
for (i=1;i<=n;++i)
fo<<s;
fo.close();
return 0;
}
problema sa rezolvat