杭电acm--2029
2015-09-15 22:40
260 查看
“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。请写一个程序判断读入的字符串是否是“回文”。
[align=left]Input[/align]
输入包含多个测试实例,输入数据的第一行是一个正整数n,表示测试实例的个数,后面紧跟着是n个字符串。
[align=left]Output[/align]
如果一个字符串是回文串,则输出"yes",否则输出"no".
[align=left]Input[/align]
输入包含多个测试实例,输入数据的第一行是一个正整数n,表示测试实例的个数,后面紧跟着是n个字符串。
[align=left]Output[/align]
如果一个字符串是回文串,则输出"yes",否则输出"no".
#include<stdio.h> #include<stdlib.h> #include<string.h> //#include<math.h> //#define SIZE 100 void main() { int n,i,t; char c, arr[100]; scanf("%d\n", &n); while (n-- > 0) { int count = 0; for (i = 0; (c = getchar()) != '\n'; i++) { arr[i] = c; t = i; } for (int i = 0, j = t; i<t / 2; i++, j--) if (arr[i] == arr[j]) { count++; } if(count==t/2) printf("yes"); else printf("no"); printf("\n"); } system("pause"); }
相关文章推荐
- BCP导出导入
- 一个简单的物料防错DEMO
- knn代码
- Android emulator 不能使用的问题
- 堆和栈的区别
- Mike and Fax
- Unity物理引擎:关节简介(固定关节)
- 小C的故事(快速学C语言,,,极速版!)
- J2EE中你必须了解的13种技术规范
- Lecture2-1Perceptron Hypothesis Set
- StoryBoard--01
- 学习在Weblogic中查看JNDI树图解
- 2015年9月15日工作日志-------------赵鑫
- 易元平台-功能树
- [转载]HTTP POST GET 本质区别详解
- 必要紧张不要怀疑自己
- Unity3D中如何调用序列帧图片为动画
- UVALive 6656 Watching the Kangaroo(二分)
- SPARK SQL华为应用现状分析
- 为什么Long类型的比float类型的范围小?