📌  相关文章
📜  检查字符串是否为回文 cpp - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:57.993000             🧑  作者: Mango

代码示例1
// Check whether the string is a palindrome or not.
#include 

using namespace std;

int main(){
    string s;
    cin >> s;
    
    int l = 0;
    int h = s.length()-1;

    while(h > l){
        if(s[l++] != s[h--]){
            cout << "Not a palindrome" << endl;
            return 0;
        }
    }
    cout << "Is a palindrome" << endl;
    return 0;

}