Advertisement
H-a-y-K

Untitled

Apr 5th, 2021
945
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 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.  
  16.     for (int i = 0; text[i] != '\0'; i++)
  17.     {
  18.         if (open == -1)
  19.         {
  20.             if (text[i] == '(')
  21.                 open = i;
  22.             else
  23.                 result[i] = text[i];
  24.         }
  25.         else if (text[i] == ')')
  26.             close = i;
  27.         else if (close != -1)
  28.         {
  29.             result[i - open - 2] = text[i];
  30.         }
  31.     }
  32.  
  33.     std::cout << result;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement