Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- int main(){
- int t;
- scanf("%d", &t);
- for(int count=0; count<t; count++){
- string s, aux, aux2;
- int abierto=0, cerrado=0;
- cin >> aux2;
- s.push_back('0');
- s.append(aux2);
- for(int i=1; i<s.size();i++){
- if(s[i]!='0'){
- aux.push_back(s[i]);
- }else if(abierto<(s[i]-'0')){
- while(abierto<(s[i]-'0')){
- aux.push_back('(');
- abierto++;
- }
- aux.push_back(s[i]);
- }else{
- aux.push_back(s[i]);
- while(cerrado<abierto){
- aux.push_back(')');
- cerrado++;
- abierto--;
- }
- }
- }
- printf("Case #%d: ", count+1);
- cout << aux;
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement