竞赛讨论区 > 通过率98% 想请问错了哪里
头像
js557
发布于 2019-02-17 23:31
+ 关注

通过率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;
}

全部评论

(0) 回帖
加载中...
话题 回帖

本文相关内容

等你来战

查看全部

热门推荐