Skip to content

Instantly share code, notes, and snippets.

@Nishant0073
Created October 4, 2022 08:48
Show Gist options
  • Save Nishant0073/35185ef2a21a8915a72668a91d5a61b3 to your computer and use it in GitHub Desktop.
Save Nishant0073/35185ef2a21a8915a72668a91d5a61b3 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int ns = 0;
int i=0;
int n = s.size();
while(i<n)
{
if(s[i]=='{')
{
cout<<'{'<<endl;
ns+=2;
for(int j=0;j<ns;j++)
cout<<"*";
}
else if(s[i]=='[')
{
cout<<endl;
for(int j=0;j<ns;j++)
cout<<"*";
cout<<'['<<endl;
ns+=2;
for(int j=0;j<ns;j++)
cout<<"*";
}
else if(s[i]==']')
{
cout<<endl;
ns-=2;
for(int j=0;j<ns;j++)
cout<<"*";
cout<<']';
}
else if(s[i]=='}')
{
cout<<endl;
cout<<'}'<<endl;
ns-=2;
}
else if(s[i]==',')
{
cout<<s[i]<<endl;
for(int j=0;j<ns;j++)
cout<<"*";
}
else
cout<<s[i];
i++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment