Advertisement
oleg_drawer

Untitled

May 3rd, 2020
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4.  
  5.  
  6. int main() {
  7.     ios_base::sync_with_stdio(false);
  8.     cin.tie(0);
  9.  
  10.     int n;
  11.     cin >> n;
  12.     int i = 1;
  13.     int cnt = 0;
  14.     while(cnt < n){
  15.         for(int j = 0; j < i && cnt < n; j++){
  16.             cout << "(";
  17.             cnt++;
  18.         }
  19.         for(int j = 0; j < i && cnt < n; j++){
  20.             cout << ")";
  21.             cnt++;
  22.         }
  23.         i++;
  24.     }
  25.  
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement