school/cs142/smcquay/lab04/num_set.cc
2016-04-06 20:45:34 -07:00

39 lines
1.0 KiB
C++

#include <iostream>
#include <sstream>
#include <iomanip>
#include "num_set.h"
vector<string> zerone = {"0", "1"};
vector<string> generate_numbers(int constant_index, int compliment) {
vector<string> r;
stringstream out;
out << compliment;
auto compliment_str = out.str();
for(int i=0; i <= 1; i++) {
for(int j=0; j <= 1; j++) {
for(int k=0; k <= 1; k++) {
for(int l=0; l <= 1; l++) {
ostringstream cur_str;
cur_str << i << j << k << l;
string s = cur_str.str();
s.insert(s.size() - constant_index, compliment_str);
r.push_back(s);
}
}
}
}
return r;
}
ostream & operator<<(ostream & os, const vector<string> & nums) {
for (unsigned int i = 0; i < nums.size(); i++) {
os << setw(4) << str2int(nums[i]);
if(i % 4 == 3 and i != nums.size() - 1) {
os << endl;
}
}
return os;
}