CSU - 1029 Palindrome(回文串)
来源:互联网 发布:如何进入人工智能行业 编辑:程序博客网 时间:2024/04/28 17:45
题目:
Description
A palindrome is a symmetrical string, that is, a string read the same from left to right as from right to left. You are asked to write a program which, given a string, determines whether it is a palindrome or not.
Input
The first line contain a single integer T, indicates the number of test cases.
T lines follow, each line contain a string which you should judge. The length of the string is at most 1000.
Output
Print one line for each string, if it is a palindrome, output “YES”, else “NO”.
Sample Input
2
aba
ab
Sample Output
YES
NO
判断是否为回文串
代码:
#include<iostream>#include<string.h>using namespace std; int main(){ int t; cin >> t; char c[1002]; cin.getline(c, 1002, '\n'); while (t--) { cin.getline(c,1002,'\n'); int l = strlen(c); bool flag = true; for (int i = 0; i + i < l; i++) { if (c[i] != c[l - 1 - i]) { flag = false; break; } } if (flag)cout << "YES"; else cout << "NO"; cout << endl; } return 0;}
0 0
- CSU - 1029 Palindrome(回文串)
- Palindrome(回文串)
- CSU 1029 Palindrome
- poj1159(Palindrome+回文串)
- Palindrome (动态规划) 构成回文串
- poj3974 Palindrome (最长回文子串)
- poj_3974 Palindrome(最长回文子串)
- LeetCode 336 Palindrome Pairs(回文串)
- Palindrome Number(回文串)
- 回文串问题 Palindrome
- Palindrome回文串
- CSU 1328 近似回文词(最长回文子串变形)
- POJ 3974 Palindrome 回文串
- poj3974 Palindrome,回文串,Manacher
- POJ1159:Palindrome(回文数)
- palindrome-number(回文数)
- Palindrome Number(回文数字)
- 回文排列(Palindrome Permutation)
- 自定义图片视图的坑
- Java堆内存
- 8.25疑难解答
- ecm 面向连接电子模型开发工具包
- [React Native混合开发]React Native for iOS之代码结构
- CSU - 1029 Palindrome(回文串)
- 1026: [SCOI2009]windy数
- Android开发艺术探索笔记 第四章
- 虚函数及纯虚函数
- 如何在海量数据中查找最相似的topk样本
- Markdown - 写作的博客神器,没有之一
- net 通讯开发工具包
- MySQL中函数CONCAT及GROUP_CONCAT
- 古老的xst攻击