B2124 题解

· · 题解

介绍一个有用的函数:

reverse函数:将给定字符串进行翻转。如果翻转过后的字符串与原字符串相同,则原字符串是回文串。

#include<bits/stdc++.h>
using namespace std;
string a,b;

int main() {
    cin >> a;
    b = a;
    reverse(a.begin(), a.end());

    if(a == b) printf("yes\n");
    else printf("no\n");
    return 0;
}