Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Task

a guest Apr 4th, 2020 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<string>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.  
  8.     int t;
  9.     scanf("%d", &t);
  10.  
  11.     for(int count=0; count<t; count++){
  12.  
  13.         string s, aux, aux2;
  14.         int abierto=0, cerrado=0;
  15.         cin >> aux2;
  16.  
  17.         s.push_back('0');
  18.         s.append(aux2);
  19.  
  20.         for(int i=1; i<s.size();i++){
  21.             if(s[i]!='0'){
  22.                 aux.push_back(s[i]);
  23.             }else if(abierto<(s[i]-'0')){
  24.                 while(abierto<(s[i]-'0')){
  25.                     aux.push_back('(');
  26.                     abierto++;
  27.                 }
  28.                 aux.push_back(s[i]);
  29.             }else{
  30.                 aux.push_back(s[i]);
  31.                 while(cerrado<abierto){
  32.                     aux.push_back(')');
  33.                     cerrado++;
  34.                     abierto--;
  35.                 }
  36.             }
  37.         }
  38.  
  39.         printf("Case #%d: ", count+1);
  40.         cout << aux;
  41.         printf("\n");
  42.     }
  43.  
  44.     return 0;
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top