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

 

转载于:https://www.cnblogs.com/Auroras/p/10800721.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值