1 条题解

  • 0
    @ 2025-12-4 18:25:55
    #include <bits/stdc++.h>
    using namespace std;
    int main(){
        string s,s2="";
        int len;
        cin >> s;
        //
        len=s.length();
        for(int i=len-1;i>=0;i--){
            s2+=s[i];
        }
        if(s==s2) cout << "yes";
        else cout << "no";
        //第二种
        bool is=true;
        for(int i=0,j=len-1;i<len/2;i++,j--){
            if(s[i]!=s[j]){
                is=false;
                break;
            }
        }
        if(is) cout << "yes";
        else cout << "no";
        //第三种
        s2=s;
        reverse(s2.begin(),s2.end());
        if(s==s2)
    }
    
    • 1

    判断字符串是否为回文字符串(基础练习)

    信息

    ID
    1023
    时间
    1000ms
    内存
    256MiB
    难度
    7
    标签
    递交数
    34
    已通过
    9
    上传者