通过率98% 想请问错了哪里

#include<bits/stdc++.h>
using namespace std;
 
int main(){
    char str[100005] ,c;
    int i=0;
    memset(str,0,sizeof(str));
 gets(str); 
    for(i=0;str[i]!='\0';i++){}
    int pos=0;
    int beg=0,end=i-1;
    while(beg<=end){
        if(str[beg]!=str[end]){
            if(str[beg+1]==str[end]){
                beg++;
            }else if(str[beg]==str[end-1]){
                end--;
            }else{//abccfgba
                cout<<"No";
                return 0;
            }
            pos++;
            if(pos>1){
                break;
            }
        }
        beg++;
        end--;
    }
    cout<<(pos>1?"No":"Yes");
 
    return 0;
}

全部评论

相关推荐

喜欢飞来飞去的雪碧在...:可以试一试字节
点赞 评论 收藏
分享
LemontreeN:有的兄弟有的我今天一天面了五场,4个二面一个hr面
投递字节跳动等公司9个岗位
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
今天 17:30
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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