46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
#include <iostream>
|
|
#include <vector>
|
|
#include <algorithm>
|
|
#include <ctime>
|
|
#include "num_set.h"
|
|
|
|
using namespace std;
|
|
|
|
const string usage = "usage: magic ";
|
|
|
|
int main(int argc, char * argv[]) {
|
|
string play_again;
|
|
srand(time(NULL));
|
|
while (true) {
|
|
string cur_guess_str;
|
|
for(int i=0; i < 5; i++) {
|
|
int compliment = rand() % 2;
|
|
vector<string> nums = generate_numbers(i, compliment);
|
|
cout << nums << endl << endl;
|
|
string cur_guess;
|
|
cout << "is your number in there: ";
|
|
cin >> cur_guess;
|
|
if(cur_guess[0] == 'y' or cur_guess[0] == 'Y') {
|
|
if(compliment == 0)
|
|
cur_guess_str.push_back('0');
|
|
else
|
|
cur_guess_str.push_back('1');
|
|
} else {
|
|
if(compliment == 0)
|
|
cur_guess_str.push_back('1');
|
|
else
|
|
cur_guess_str.push_back('0');
|
|
}
|
|
}
|
|
reverse(cur_guess_str.begin(), cur_guess_str.end());
|
|
cout << cur_guess_str << ", " << str2int(cur_guess_str) << endl;
|
|
cout << "play again? ";
|
|
cin >> play_again;
|
|
|
|
if(!(play_again[0] == 'y' or play_again[0] == 'Y'))
|
|
break;
|
|
}
|
|
cout << "good bye" << endl;
|
|
return 0;
|
|
}
|