回文

编程判断输入的一个字符串是否是“回文”。所谓“回文”字符串就是从左读和从右读都一
样的字符串。例如: "abcba"就是一个回文字符串。
要求:先输出("Input a string: "),输入字符串,然后判断是否回文,最后输出
("This string is a plalindrome. ")或者("This string is not a plalindrome. ")

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 
 5 int fun(char a[])
 6 {
 7     int i,j;
 8     for (i=0,j=strlen(a); i<j; i++, j--)
 9     {
10         if (a[i]!=a[j])
11         {
12             return 0;
13         }
14     }
15     return 1;
16 }
17 
18 int main()
19 {
20     char a[80];
21     printf("Input a string:
");
22     gets(a);
23     if(fun(a))
24         printf("This string is a plalindrome.
");
25     else
26         printf("This string is not a plalindrome.
");
27     return 0;
28 }
原文地址:https://www.cnblogs.com/crane-practice/p/3727974.html