#include <iostream>
#include <string.h>
using namespace std;
int main() {
int d=1,j=0,i;
char a[100],b[100];
cin>>a;
for(i=strlen(a)-1;i>=0;i--)
{
b[j]=a[i];
j++;
}
// cout<<a<<endl<<b;
try
{
if(strcmp(a,b)==0)
cout<<a<<" is a palindrome";
else
throw(d);
}
catch(int e)
{
cout<<a<<" is not a palindrome";
}
return 0;
}
#include <string.h>
using namespace std;
int main() {
int d=1,j=0,i;
char a[100],b[100];
cin>>a;
for(i=strlen(a)-1;i>=0;i--)
{
b[j]=a[i];
j++;
}
// cout<<a<<endl<<b;
try
{
if(strcmp(a,b)==0)
cout<<a<<" is a palindrome";
else
throw(d);
}
catch(int e)
{
cout<<a<<" is not a palindrome";
}
return 0;
}
No comments:
Post a Comment