一个判断回文的程序求教(实在想不通)
/*此程序的目的是输入一个字符串,判断是否是回文(比如abba,dijid就是回文)*/#include<stdio.h>
#include<string.h>
int i=0;
char a[256]={0};
void first();
int pdhw(char ax[]);
void main()
{
first();
if(pdhw(a))
printf("It is not a huiwen.");
else
printf("It is a huiwen.");
getchar();
}
void first()
{
int pass=1,oh;
while(pass)
{
printf("Please input a word.\n");
printf("The word:");
while(a[i]!='\n')
{
if(i!=0)
i++; //这里不知道怎么的i不能增加
scanf("%c",&a[i]);
}
if(i<=1)
{
printf("It is not allowed!\n");
printf("Please input again.\n");
}
else
pass=0;
}
}
int pdhw(char ax[])
{
int x;
for(x=0,i--;(x<=i)||(i!=x);x++,i--)
if(ax[x]!=ax[i])
{
return 0;
break;
}
return 1;
}