-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.cpp
58 lines (47 loc) · 1.22 KB
/
game.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
int n, x;
int a;
bool cerrar=true;
srand(time(0));
do
{
cout<<"\t+++++ GUESS +++++"<<endl<<endl;
cout<<"\t- 1. Play\n";
cout<<"\t- 2. Exit\n"<<endl<<endl;
cout<<"\t- Choose an option: ";
cin>>a;
cout<<endl;
switch(a)
{
case 1:
cout<<"Set a max number: ";
int max;
cin>>max;
n=rand()%max+1;
cout<<endl;
cout<<"I've thought a number. Do you know what is it?" <<endl;
do{
cin>>x;
if(x>n)
cout<<"Incorrect. Number is smaller\n";
if(x<n)
cout<<"Incorrect. Number is bigger\n";
if(x==n)
cout<<"GOTCHA!"<<endl;
cout<<endl;
}while(x!=n);
break;
case 2:
cerrar=false;
break;
default:
cout<<"Opcion no valida"<<endl;
cout<<endl;
}
}while(cerrar==true);
}