5 条题解

  • 4
    @ 2017-10-20 15:32:38
    a=input()
    i=0
    j=len(a)-1
    while i<=j:
        if a[i]==a[j]:
            i+=1
            j-=1
        else:
            print('no')
            exit()
    print('yes')
    
    
  • 1
    @ 2024-05-06 17:13:59

    升级版回文串

    #include <iostream>
    #include <string>
    #include <cmath>
    using namespace std;
    string PalindromicString(string str){//输入中文会有BUG
        int len=str.size();
        string res="yes";
            int half;
            if(len%2==0){
                half=len/2;
            }
        else{
                half=ceil(len/2);
        }
        for(int i=1;i<=half;i++){
            if(str[i-1]!=str[len-i]){//数组越界:(
                res="no";
                        break;
                }
        }
        return res;
    }
    
    int main(){
        string str,res;
        cin>>str;
        res=PalindromicString(str);
        cout<<res<<endl;
        return 0;
    }
    
  • 1
    @ 2019-06-17 23:00:39

    s=input()

    n=len(s)
    ishw='bala'
    for i in range(n):
    if(s[i]!=s[n-i-1]):
    ishw='sss'

    if ishw=='bala':
    print("yes")
    else:
    print("no")

  • 1
    @ 2018-10-29 13:05:17

    #include <stdio.h>
    #include <cstring>
    #include <iostream>
    using namespace std;
    string s;
    int main()
    {
    cin>>s;
    for(int i=0,j=s.length()-1;i<=j;i++,j--)
    if(s[i]!=s[j])
    {
    cout<<"no";
    return 0;
    }
    cout<<"yes";
    return 0;
    }

  • 0
    @ 2017-10-17 17:21:48

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    string a;
    cin>>a;
    int c=a.length();
    for(int i=0;i<c;i++)
    if(a[i]!=a[c-i-1])
    {
    cout<<"no"<<endl;
    return 0;
    }
    cout<<"yes"<<endl;
    return 0;
    }

  • 1

信息

难度
3
分类
(无)
标签
(无)
递交数
2329
已通过
704
通过率
30%
被复制
1
上传者