My Code Goes Here
#include
using namespace std;
int main() {
int t;
cin>>t;
while(t–){
int count=0,state=0;
string s;
cin>>s;
for(int i=0;i<s.length();i++){
if(s[i]==‘(’)
count++;
else
state++;}
for(int i=0;i<count;i++)
{
cout<<“(”;
}
for(int i=0;i<state;i++)
{
cout<<“)”;
}
}
return 0;
}
add the header file name (after #include put)
and use the decrement function correctly while(t–) not while(t-)
Khushi thanks for the response.
I did that correct its typing mistake dont know how I already done as you have told. Could you please revisit the question and check by copy pasting the code.Hope you will again answer…
#include
using namespace std;
int main() {
int t;
cin>>t;
while(t–){
int count=0,state=0;
string s;
cin>>s;
for(int i=0;i<s.length();i++){
if(s[i]==‘(’)
count++;
else
state++;}
for(int i=0;i<count;i++)
{
cout<<“(”;
}
for(int i=0;i<state;i++)
{
cout<<“)”;
}
}
return 0;}
i hope this works now but in the else condition it is going to print “)” for every character else than (.for example it will print (() for ((2
answer shows wrong yet.
THANKS KHUSHI.