第1个回答 2013-04-24
#include(stdio.h)
int str_len(char *p)
{
int n=0;
while(*p!='\0')
{
n++;
p++;
}
return n;
}
int main()
{
char a[255];
int n,i;
printf("输入一个字符串:\n");
gets(a);
n=str_len(a);
for(i=0;i<n/2;i++){
if(a[i]!=a[n-1]){
printf("N\n");
return 0;
}
}
printf("Y\n");
return 1;
}
第2个回答 2013-04-24
#include<iostream>
using namespace std;
int test(char d[],int k,int i)
{
if(d[k]==d[i-k]&&k==0)
return 1;
else if(d[k]==d[i-k])
test(d,k-1,i);
else
return 0;
}
void main()
{
int i=0;n=0;
char b[255];
while((a=getchar())!=\n)
{
b[i]=a;
i++;
}
if(i%2==0)
n=test(b,(i/2),i-1);
else
n=test(b,(i/2-1),i-1);
if(n==0)
cout<<"N";
else
cout<<"Y";
}