这个为啥不对
查看原帖
这个为啥不对
403648
eddie111楼主2021/2/7 22:01
#include<iostream>
#include<string>
using namespace std;
string str;
int main(){
	cin>>str;//读入字符串
	int leng=str.length();
	int s=0;
	for(int i=0;i<(leng+1)/2;i++){
		if(str[i]=='i'&&str[leng-i-1]=='w') s++;
		if(str[i]=='w'&&str[leng-i-1]=='i') s++;
		if(str[i]==')'&&str[leng-i-1]==')') s++;
		if(str[i]=='('&&str[leng-i-1]=='(') s++;
	} 
	cout<<s<<endl;
	return 0;
}

2021/2/7 22:01
加载中...