c语言课程设计 输入一个字符串,判断是否为回文

急 拜托了

第1个回答  2008-06-11
#include <stdio.h>
#include<string.h>
void main()
{
int f(char a[]);
char a[100];
printf("请输入一个字符串:\n");
scanf("%s",&a);
if(f(a)) printf("此字符串是回文。\n");
else printf("此字符串不是回文。\n");
}

int f(char str[])
{
int i,j=strlen(str);
for(i=0;i<j/2.0;i++)
if(str[i]!=str[j-i-1])
return 0;
return 1;
}
第2个回答  2008-06-11
什么是回文??
第3个回答  2008-06-11
#include <stdio.h>
#include <string.h>
#define N 50
void main()
{
int i,x=0;
char st1[N+1];
char *pst1,*pst2;
printf("please input a string:");
scanf("%s",st1);
pst1=st1;
pst2=st1;
while(*pst1!='\0')
pst1++;
i=0;
pst1--;
while(*pst1==*pst2 && *pst1!='\0')
{

pst1--;
pst2++;
i++;
}
x=strlen(st1);
if(i==x)
printf("yes\n");
else
printf("no\n");

}本回答被提问者采纳
相似回答