Palindromes _easy version
来源:互联网 发布:淘宝零食店排行榜 编辑:程序博客网 时间:2024/06/08 13:30
Palindromes _easy version
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 41117 Accepted Submission(s): 24999
Problem Description
“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。请写一个程序判断读入的字符串是否是“回文”。
Input
输入包含多个测试实例,输入数据的第一行是一个正整数n,表示测试实例的个数,后面紧跟着是n个字符串。
Output
如果一个字符串是回文串,则输出"yes",否则输出"no".
Sample Input
4levelabcdenoonhaha
Sample Output
yesnoyesno
Author
lcy
Source
C语言程序设计练习(五)
Recommend
lcy | We have carefully selected several similar problems for you: 1040 2091 1076 2046 2501
#include<iostream>#include<cstdlib>#include<cstdio>#include<cmath>#include<cstring>#include<string>#include<cstdlib>#include <set>#include<algorithm>#include <limits.h>#include <ctype.h>#include <map>#include <stack>typedef long long LL;using namespace std;const int N = 105;int data[N][N];int dp[N][N];int f[35];char c[6] = {'A', 'B', 'C', 'D', 'E', 'F'};float obj[5];void fun(int n, int m){ int flag = 0; if(n < 0){ flag = 1; n = -n; } stack<char> s1; while(n != 0){ int yushu = n % m; if(yushu >= 10){ s1.push(c[yushu - 10]); }else { s1.push(yushu + '0'); } n = n / m; } if(flag){ cout << "-"; } while(!s1.empty()){ cout << s1.top(); s1.pop(); } cout << endl;}int gcd(int a, int b){ return b == 0 ? a : gcd(b, a % b);}int lcm(int a, int b){ return a / gcd(a, b) * b;}int main() { //freopen("out.txt","w",stdout);// int n, sum;// while(scanf("%d %d", &n, &sum) != EOF){// if(n == 0 && sum == 0) break;// for(int i = 1; i <= n; i++){// int T = 0;// for(int j = i; j <= n; j++){// T += j;// if(T == sum ){// cout << "["<< i << "," << j <<"]"<< endl;// break;// }else if(T < sum){// continue;// }else {// break;// }// }// }// cout << endl;// } //freopen("in.txt","r",stdin); int n; cin >> n; getchar(); while(n--){ string str; getline(cin, str); int flag = 1; for(int i = 0; i < str.size() / 2; i++){ if(str[i] != str[str.size() - i - 1]){ flag = 0; break; } } if(flag){ cout << "yes" << endl; }else { cout << "no" << endl; } } return 0;}
0 0
- 2029 Palindromes _easy version
- HDT_2029 Palindromes _easy version
- hdoj_2029 Palindromes _easy version
- hdu-Palindromes _easy version
- 1251 Palindromes _easy version
- Palindromes _easy version
- Palindromes _easy version
- hdu2029 Palindromes _easy version
- Palindromes _easy version
- 2029 Palindromes _easy version
- Palindromes _easy version
- hdoj Palindromes _easy version
- HDU2029 Palindromes _easy version
- Palindromes _easy version
- Palindromes _easy version
- 2029 Palindromes _easy version
- Palindromes _easy version
- HDU2029 Palindromes _easy version
- UrlHttpUtils使用介绍
- python数据分析2
- vim开发Node.js
- Spark集群搭建
- 偶数求和
- Palindromes _easy version
- Java多线程(一)- 基础概念
- 自定义TextView
- 09-S3C2440驱动学习(三)嵌入式linux-platform平台总线驱动程序及分离分层构建驱动框架
- lintcode(646)First Position Unique Character
- 复习时间
- Myeclipse:使用Servlet中文出现乱码解决方案
- 组合模式
- 双面柔性线路板网印中 要留意的疑问