Programma c++ - Palindroma

# include <iostream.h>
#include <string.h>
int main()
{
int j,i,n,x=0;
char v1[20],v2[20];
cout<<"scrivi una parola: ";
cin>>v1;
n=strlen(v1);
for (i=0,j=n-1;i<n;i++,j--)
v2=v1[j];
for (i=0;i<n;i++)
{
if (v2!=v1)
x=1;
}
if (x==0)
cout<<v1<<": e' palindroma"<<endl;
else
cout<<v1<<": non e' palindroma"<<endl;
return 0;
}

Registrati via email