Advertisement
H-a-y-K

Untitled

Apr 5th, 2021
908
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char text[255];
  9.     char result[255];
  10.  
  11.     cin.getline(text, 255);
  12.  
  13.     int open = -1;
  14.     int close = -1;
  15.     int size = 0;
  16.  
  17.     for (int i = 0; text[i] != '\0'; i++)
  18.     {
  19.         if (open == -1)
  20.         {
  21.             if (text[i] == '(')
  22.                 open = i;
  23.             else
  24.             {
  25.                 result[i] = text[i];
  26.                 size++;
  27.             }
  28.         }
  29.         else if (text[i] == ')')
  30.             close = i;
  31.         else if (close != -1)
  32.         {
  33.             result[i - open - 2] = text[i];
  34.             size++;
  35.         }
  36.     }
  37.  
  38.     result[size] = '\0';
  39.     std::cout << result;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement