I'm totally lost in my c++ class.. can someone guide me or help me??

Problem 1
Write a C++ program that writes all binary sequences of length 15
into a file binary15.txt.
-The sequences must be in increasing lexicographic order. The output filestream must be created with the command ofstream out("binary15.txt");
-Each sequence must be on a new line and the zeros and ones must not be separated by spaces. See below how the file must look like.

Beginning of file binary15.txt:
000000000000000
000000000000001
000000000000010
000000000000011

Problem 2
Write a C++ program that writes all nontrivial binary sequences of
length 15 with constant autocorrelation into a file binary15a.txt.
Hint: There are exactly 60 such sequences.
-The sequences must be in increasing lexicographic order. The output filestream must be created with the command ofstream out("binary15a.txt");
-The format of the file binary15a.txt is as in Problem 1.

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by AirGear

this is what i got so far. can someone point me to the right track?

vector<int>v(15);
for(int i=0; i<v.size(); i++)
cout << v;
cout << endl;

v.pop_back();
v.push_back(1);
for(int i=0; i<v.size(); i++)
cout << v;
cout << endl;

v.pop_back();
v.pop_back();
v.push_back(1);
v.push_back(0);
for(int i=0; i<v.size(); i++)
cout << v;
cout << endl;

v.pop_back();
v.push_back(1);
for(int i=0; i<v.size(); i++)
cout << v;
cout << endl;

i don't get used to use vector, so i don't really understand your code..
but i think you can create a function that takes int parameter of 0 to 14, and process it using div and mod.

i don't get used to use vector, so i don't really understand your code..
but i think you can create a function that takes int parameter of 0 to 14, and process it using div and mod.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.