题解 | 小红的回文串

小红的回文串

https://www.nowcoder.com/practice/b0c3a7aecb0a47ab865602585f4402a7

#include <iostream>
#include<string>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    string s,_s;
    while(t--){
        cin>>s;
        _s="";
        int k=1;
        for(char ch:s){
            if(ch=='d'||ch=='p'||ch=='q')
            _s+='b';
            else if(ch=='w')
            _s+="vv";
            else if(ch=='m')
            _s+="uu";
            else if(ch=='n')
            _s+='u';
            else
            _s+=ch;
        }
        int left=0,right=_s.size()-1;
        while(left<right){
            if(_s[left]!=_s[right]){
            k=0;
            break;
            }
            left++;
            right--;
        }
        if(k==0)
        cout<<"NO\n";
        else
        cout<<"YES\n";
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

09-26 19:45
门头沟学院 Java
点赞 评论 收藏
分享
10-16 19:16
Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务