4个RE请问哪里有错
查看原帖
4个RE请问哪里有错
1191207
wmhwuminhao楼主2024/3/2 12:26
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string s1 , s2 ;
int x , cc ;
int main(){
	cin >> s1 ;
	while ( s1[cc] != '\0' ){
		if ( s1[cc] == '(' ) {
			cout << s1[cc] ;
			s2[cc] = s1[cc] ;
			x++ ; 
		}
		if ( s1[cc] == ')' ) {
			if ( x != 0 ) {
				cout << s1[cc] ;
				x-- ;
			} else cout << "(" << s1[cc] ;
		} 
		cc++ ;
	}
	while ( x != 0 ) {
		cout << ")" ;
		x-- ;
	}
	return 0;
}
2024/3/2 12:26
加载中...