Answer the question
In order to leave comments, you need to log in
Segmentation error (memory stack flushed to disk) c++. How to fix?
There is an error in this code snippet. I just can't understand what's the matter.
The program itself must return a binary sequence of length n
#include <iostream>
#include <vector>
using namespace std;
void func(int a, vector<int>& v1){
if(a == v1.size()){
for(int i = 0; i < v1.size(); ++i){
cout << v1[i];
}
cout << endl;
return;
}
for(int i = 0; i < v1.size(); ++i){
v1[a] = i;
func(i + 1, v1);
}
}
int main(){
int n;
cin >> n;
vector<int> v;
for(int i = 0; i < n; ++i){
v.push_back(0);
}
for(int i = 0; i < n; ++i){
cout << v[i];
}
func(1, v);
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question