RE求调
查看原帖
RE求调
712410
huihui_qwq楼主2022/8/31 13:45
#include<bits/stdc++.h>
using namespace std;
bool check(char ch1,char ch2){
    if(ch1==ch2)
        return true;
    else if(ch1=='('&&ch2==')')
        return true;
    else if(ch1==')'&&ch2=='(')
        return true;
    return false;
}
string str;
int ans;
int main(){
    scanf("%s",&str);
    int len=(str.length()+1)/2;
    for(int i=0;i<len;i++)
        if(!check(str[i],str[str.length()-i-1]))
            ans++;
    printf("%d\n",ans);
    return 0;
}
2022/8/31 13:45
加载中...