Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- void find(int r, bool easier){
- bool found = false;
- int n;
- int count = 0;
- bool cheat=false;
- while(not found and cin >> n){
- if(n == 10000){
- cout << "You cheater huh?" << endl;
- cout << "Okay then... Answer is " << r << endl;
- cheat=true;
- }
- ++count;
- if(n == r) found=true;
- else if(easier){
- if(n<r) cout << "The answer is higher than that!" << endl;
- else cout << "The answer is lower than that!" << endl;
- }
- }
- if(found){
- cout << endl << "The number was " << r << "!" << endl;
- cout << "Total attempts: " << count << endl << endl;
- cout << "Continue?" << endl;
- if(cheat) cout << "You're a cheater anyway..." << endl;
- }
- }
- int main(){
- int r;
- int dif;
- string y;
- do{
- cout << "Choose your difficulty!" << endl;
- cout << "1: coinflip; 2: easy; 3: hard; 4: SHINY" << endl;
- cin >> dif;
- dif-=1;
- dif%=4;
- if(dif==0) r = rand() % 2;
- else if(dif==1) r = rand() % 10;
- else if(dif==2) r = rand() % 100;
- else r = rand() % 4096;
- bool easier;
- cout << "Easier mode? 1: yes; 0: no" << endl;
- int em;
- cin >> em;
- em%=2;
- if(em==1) easier=true;
- else easier=false;
- find(r, easier);
- } while(cin >> y and y!="no");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement