Palindromes _easy version(reverse)

Problem Description
“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。请写一个程序判断读入的字符串是否是“回文”。
 
Input
输入包含多个测试实例,输入数据的第一行是一个正整数n,表示测试实例的个数,后面紧跟着是n个字符串。
 
Output
如果一个字符串是回文串,则输出"yes",否则输出"no".
 
Sample Input
4 level abcde noon haha
 
Sample Output
yes
no
yes
no 
      
 1 #include<iostream>
 2 #include<iomanip>
 3 //#include<bits/stdc++.h>
 4 #include<cstdio>
 5 #include<cmath>
 6 #include<string>
 7 #include<sstream>
 8 #include<algorithm>
 9 #define PI  3.14159265358979
10 #define LL long long
11 #define  eps   0.00000001
12 #define LL long long
13 using namespace std;
14 int main()
15 {
16     string s;
17     int T;
18     cin>>T;
19     while(T--)
20     {
21         cin>>s;string c=s;
22         reverse(s.begin(),s.end());
23         if(s==c) cout<<"yes"<<endl;
24         else cout<<"no"<<endl;
25 
26     }
27 }
View Code

猜你喜欢

转载自www.cnblogs.com/Auroras/p/10800721.html