[C++]回文字符串判断

版权声明:Copyright © 2018-2018 Takaway 复习用,转载注明一下就行了~ https://blog.csdn.net/LynlinBoy/article/details/83829897
#include <iostream>
#include <string>
using namespace std;
inline bool is_palindrome(const string str) {
    int length = str.length();
    for (int i = 0; i < length / 2; ++i)
        if (str[i] != str[length - i - 1])
            return false;
    return true;
};
int main(int argc, char *argv[]) {
    ios::sync_with_stdio(false);
    string str; cin >> str;
    if (is_palindrome(str)) cout << "YES";
    else cout << "NO"; cout.put('\n');
    return 0;
};

猜你喜欢

转载自blog.csdn.net/LynlinBoy/article/details/83829897