when I run in sublime all working properly but when I run here, it’s giving me error
Its giving error
#include<iostream>
using namespace std;
void gen_para(int i, int n,int open, int close, char* a){
if(i == 2*n){
a[i]=’\0’;
cout<<a<<endl;
return;
}
// when open
if(open<n){
a[i]=’(’;
gen_para(i+1,n,open+1,close,a);
}
// when close
if(close<open){
a[i]=')';
gen_para(i+1,n,open,close+1,a);
}
return;
}
int main() {
char a[10];
int n;
cin>>n;
gen_para(0,4,0,0,a);
return 0;
}
I changes the size of char too ,but still same error.
a)
it size should be atleast 2*n+1.
check maximum value of n and then declare its size accordingly.
b)
interchnage the position of these two if statemnts to generate output in lexicographical order
Done the changes, but still error is showing
pls share ur code using cb ide
a) paste ur code here->https://ide.codingblocks.com/
b) press ctrl + s
c) a link will be generated in ur search bar
share that link with me
check now->
oh sorry, my mistake; made an error while copying from sublime;
Thank you for helping
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.