Skip to content

Instantly share code, notes, and snippets.

@satyajeetkrjha
Last active July 11, 2022 08:46
Show Gist options
  • Select an option

  • Save satyajeetkrjha/771a48b9557bdf9a480e337892d6084b to your computer and use it in GitHub Desktop.

Select an option

Save satyajeetkrjha/771a48b9557bdf9a480e337892d6084b to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <stack>
using namespace std;
int main() {
string line ;
string res ;
while(getline(cin,line)){
for(int i =0 ; i<line.size();i++){
char ch = line[i];
if(ch == '(' || ch == '{' || ch == '[' || ch == ']' || ch == '}' || ch == ')'){
res+= ch;
}
}
}
cout << "res is " << res << endl; // moving this at line 17 prints but here it does not print anything
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment