-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpetit jeu.cpp
47 lines (39 loc) · 963 Bytes
/
petit jeu.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
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SARRITZU Peter
On W10
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <iostream> //entete de gestion des E/S
using namespace std;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fonction principale
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
int main()
{
srand(time(NULL));
unsigned short alea, nbUser,nbCoupsMax,nbCoups ;
do {
alea = rand();
} while (alea > 100 || alea == 0);
cout << "Coups Max ? " << endl;
cin >> nbCoupsMax;
nbCoups = 0;
do {
cout << "nbUser ?" << endl;
cin >> nbUser;
nbCoups = nbCoups + 1;
if (nbUser < alea) {
cout << "TROP PETIT" << endl;
}
else if (nbUser > alea) {
cout << "TROP GRAND" << endl;
}
else {
cout << "Gagner en " << nbCoups <<"Coup(s)" << endl;
}
} while (nbUser != alea and nbCoups <= nbCoupsMax-1);
if (nbUser = alea) {
cout << "Dommage le numero est " << alea << endl;
}
cin.get(); cin.ignore();
return EXIT_SUCCESS;
}