问题标题: 酷町堂:3990 最长回文字符串

0
0
已解决
王文博
王文博
缔造者之神
缔造者之神

不知道怎么错了,样例都是过的!

错误代码:

#include <bits/stdc++.h>
using namespace std;
string a;
int n;
bool f=1;
int check(string s)
{
    int c=0,d=s.size()-1,cnt=0;
    while(c<=d)
    {
        if(s[c]!=s[d])
        {
            f=0;
            c++;
            d--;
            continue;
        } 
        c++;
        d--;
        cnt++;
    }
    if(f==0) return cnt;
    else return (int)(s.size());
}
int main()
{
    getline(cin,a);
    for(int i=0;i<a.size();i++) if(a[i]>='A'&&a[i]<='Z') a[i]+=32;
    if(check(a)==(int)(a.size())) cout<<"Y";
    else cout<<check(a);
}

 


0
0
我要回答