赞
踩
#include<stdio.h> #include<stdlib.h> #include<string.h> int main() { char ch[101], sh[101]; int i, len, mid, next, top; top = 0; //读入字符串 gets(ch); len = strlen(ch); mid = len/2 - 1; //存入前一半 for(i = 0; i <= mid; i++) { sh[++top] = ch[i]; } //判断奇偶 if(len%2 == 0) { next = mid + 1; } else { next = mid + 2; } //判断回文 for(i = next; i < len; i++) { if(ch[i] !=sh[top]) { break; } top--; } if(top == 0) { printf("是回文\n"); } else { printf("不是回文\n"); } system("pause"); return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。