adding cs142 code
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user