[原创]回文算法
哪位给个"回文"的算法.何谓例如abcba这样的.
这也要金币啊
写这有多难
#include <stdio.h>
#define maxsize 26
int huiwen(char *a,int m,int n)
{
int k=1;
for(;m<n;)
{
while(a[m]==' ')
m++;
while(a[n]==' ')
n--;
if(a[m]==a[n])
{
m++;
n--;
}
else
{
k=0;
break;
}
}
return(k);
}
main()
{
int i,j;
char a[maxsize];
printf("输入,例如 a man a plan a canal panama\n");
gets(a);
i=0;
j=strlen(a)-1;
if(huiwen(a,i,j))
printf("this is huiwen\n");
else
printf("this isn't huiwen\n");
getch();
return 0;
}
[此贴子已经被作者于2006-5-24 12:49:38编辑过]