Plus ou Moins / Le Bon Numero

AsllaPiscu Messages postés 1 Date d'inscription mardi 8 décembre 2009 Statut Membre Dernière intervention 8 décembre 2009 - 8 déc. 2009 à 21:54
lural Messages postés 131 Date d'inscription samedi 6 janvier 2007 Statut Membre Dernière intervention 4 janvier 2011 - 9 déc. 2009 à 19:54
C'est vraiment un simple jeu classique, but trouver un bon numéro entre deux valeurs dans le minimum d'essais ! Seulement, je fais mes débuts, et je ne sais a peine que faire des codes C pour débutant, j'étudies dessus ^^ ! Bref, le programme qui va suivre suit ces règles suivantes :

Langues : Anglais/Francais
Niveaux 1-20 / 21-60 / 61-80 / 81-100 / 101-200
Debutant 1-20 : essais illimités
Moyen 21-60 : essais limités
Difficile 61-80 : essais limités, augmentation du bon numéro d'une valeur x constante à chaque essai
Expert 81-100 : essais limités, augmentation ou diminution d'une valeur x constante à chaque essai en fonction de la comparaison
Champion 101-200 : essais limités, augmentation ou diminution d'une nouvelle valeur entre 0 et x à la chaque essai en fonction de la comparaison

Le record d'un de mes proches est de 70points/100 au niveau 100 (donc 30 essais), aucun n'a réussi à partir du niveau 101 ! Desole de ne pas savoir comment le compiler en zip, alors je le met copier collé entier ci dessous :x j'espères que cela ne vous gênera pas. Je souhaiterais savoir ce que vous en pensiez du niveau de difficulté, et si quelqu'un aurait pu gagner à un niveau plus élevé !






using namespace std ;
#include
#include <stdlib.h>
#include <conio.h>
main()
{
int x, y, n, t, s, v, a, b, w;
char z;
z='o';
while (z!='n')
{
z='n';
s=0;
cout << "Choice a level difficulty between 1 and 200"<< endl;
cout << "Choisissez un niveau de difficulte entre 1 et 200"<< endl;
cout << "Beginner level:1-20 Normal level:21-60 Hard level:61-80 Expert level:81-100 Champion level:101-200" << endl;
cout << "Niveau debutant:1-20 moyen:21-60 difficile:61-80 expert:81-100 champion:101-200" << endl;
cin >> a;
if (a>=1 && a<=20)
{
t=0;
if (a==1)
{
n=50;
}
if (a==2)
{
n=100;
}
if (a==3)
{
n=200;
}
if (a==4)
{
n=500;
}
if (a==5)
{
n=1000;
}
if (a==6)
{
n=2000;
}
if (a==7)
{
n=5000;
}
if (a==8)
{
n=10000;
}
if (a==9)
{
n=25000;
}
if (a==10)
{
n=50000;
}
if (a==11)
{
n=100000;
}
if (a==12)
{
n=150000;
}
if (a==13)
{
n=200000;
}
if (a==14)
{
n=250000;
}
if (a==15)
{
n=500000;
}
if (a==16)
{
n=1000000;
}
if (a==17)
{
n=1500000;
}
if (a==18)
{
n=2000000;
}
if (a==19)
{
n=2500000;
}
if (a==20)
{
n=5000000;
}
srand(time(NULL)); // initialisation du générateur, à appeler qu'une fois dans une application
//Qu'est-ce que c'est la fonction time( ) ?
x=rand(); // un nombre aléatoire est affecté à x, 0 <= x <= 0x7FFF
y=rand() % n+1; // un nombre aléatoire est affecté à y, 0 <= y <= 100000
cout << "Find the good number between 0 and " << n << endl << " Your number of propositions would be your score, the less is the number of propositions, the better is your score !" << endl;
cout << "Trouvez le bon nombre entre 0 et " << n << endl << " Votre nombre d'essai determinera votre score, plus il est petit, mieux c'est !" << endl;
while (s!=y)
{
cout << "Tape a new proposition !"<< endl;
cout << "Tapez une nouvelle proposition !";
cin >> s;
if (s>y)
{
cout << "It's less !"<< endl;
cout << "C'est moins !"<< endl;
t=t+1;
}
if (s<y)
{
cout << "It's more !"<< endl;
cout << "C'est plus !"<< endl;
t=t+1;
}
if (s==y)
{
t=t+1;
cout <<"You've found the good number ! Your score : " << t << endl;
cout <<"Vous avez trouve le bon numéro ! Votre score : " << t << endl;
cout <<"Would you like to restart the game ? o if yes, n if no" << endl;
cout <<"Souhaitez-vous recommencer ? o si oui, n si non";
cin >> z;
cout << "Choice a level difficulty between 1 and 100"<< endl;
cout << "Choisissez un niveau de difficulte entre 1 et 100"<< endl;
cin >> a;
}
}
}
if (a>=21 && a<=60)
{
if (a==21)
{
n=50;
v=5;
}
if (a==22)
{
n=100;
v=6;
}
if (a==23)
{
n=200;
v=7;
}
if (a==24)
{
n=500;
v=8;
}
if (a==25)
{
n=1000;
v=9;
}
if (a==26)
{
n=2000;
v=10;
}
if (a==27)
{
n=5000;
v=11;
}
if (a==28)
{
n=10000;
v=12;
}
if (a==29)
{
n=25000;
v=13;
}
if (a==30)
{
n=50000;
v=14;
}
if (a==31)
{
n=100000;
v=15;
}
if (a==32)
{
n=150000;
v=16;
}
if (a==33)
{
n=200000;
v=17;
}
if (a==34)
{
n=250000;
v=18;
}
if (a==35)
{
n=500000;
v=19;
}
if (a==36)
{
n=1000000;
v=20;
}
if (a==37)
{
n=1500000;
v=21;
}
if (a==38)
{
n=2000000;
v=22;
}
if (a==39)
{
n=2500000;
v=23;
}
if (a==40)
{
n=5000000;
v=24;
}
if (a==41)
{
n=50;
v=4;
}
if (a==42)
{
n=100;
v=4;
}
if (a==43)
{
n=200;
v=4;
}
if (a==44)
{
n=500;
v=4;
}
if (a==45)
{
n=1000;
v=8;
}
if (a==46)
{
n=2000;
v=8;
}
if (a==47)
{
n=5000;
v=8;
}
if (a==48)
{
n=10000;
v=8;
}
if (a==49)
{
n=25000;
v=12;
}
if (a==50)
{
n=50000;
v=12;
}
if (a==51)
{
n=100000;
v=12;
}
if (a==52)
{
n=150000;
v=12;
}
if (a==53)
{
n=200000;
v=16;
}
if (a==54)
{
n=250000;
v=16;
}
if (a==55)
{
n=500000;
v=16;
}
if (a==56)
{
n=1000000;
v=16;
}
if (a==57)
{
n=1500000;
v=20;
}
if (a==58)
{
n=2000000;
v=20;
}
if (a==59)
{
n=2500000;
v=20;
}
if (a==60)
{
n=5000000;
v=20;
}
t=v;
srand(time(NULL)); // initialisation du générateur, à appeler qu'une fois dans une application
//Qu'est-ce que c'est la fonction time( ) ?
x=rand(); // un nombre aléatoire est affecté à x, 0 <= x <= 0x7FFF
y=rand() % n+1;
cout << "Find the good number between 0 and " << n << endl << " Your number of propositions would be limited to " << t << endl << "In the end, the more is your score, the better is !" << endl;
cout << "Trouvez le bon nombre entre 0 et " << n << endl << " Votre nombre d'essai sera limite a " << t << " !" << endl << "A la fin, plus votre score est grand, mieux c'est !" << endl;
while (s!=y)
{
cout << "Tape a new proposition !"<<endl;
cout << "Tapez une nouvelle proposition !";
cin >> s;
if (s>y && t!=0)
{
cout << "It's less !"<< endl;
cout << "C'est moins !"<< endl;
t=t-1;
cout << "It remains : " << t << " more propositions , retry !" << endl;
cout << "Il vous reste : " << t << " essais, recommencez !" << endl;
}
if (s<y && t!=0)
{
cout << "It's more !"<< endl;
cout << "C'est plus !"<< endl;
t=t-1;
cout << "It remains : " << t << " more propositions , retry !" << endl;
cout << "Il vous reste : " << t << " essais, recommencez !" << endl;
}
if (t==0 && s!=y)
{
t=t-1;
cout <<"You've not found the good number in the number of propositions you've got at the beginning !" << endl;
cout <<"Vous n'avez pas trouve le bon numero dans le nombre d'essai qui vous etait imparti !" << endl;
cout <<"Would you like to restart the game ? o if yes, n if no" << endl;
cout <<"Souhaitez-vous recommencer ? o si oui, n si non";
cin >> z;
cout << "Choice a level difficulty between 1 and 100"<< endl;
cout << "Choisissez un niveau de difficulte entre 1 et 100"<< endl;
cin >> a;
}
if (s==y)
{
t=t-1;
cout <<"It's amazing ! You've found the good number ! That's your number of propositions : " << t << endl;
cout <<"Vous avez trouve le bon numero ! Voici donc votre nombre d'essai : " << t << endl;
cout <<"Score :" << t << "/" << v << endl;
cout <<"Would you like to restart the game ? o if yes, n if no" << endl;
cout <<"Souhaitez-vous recommencer ? o si oui, n si non";
cin >> z;
cout << "Choice a level difficulty between 1 and 100"<< endl;
cout << "Choisissez un niveau de difficulte entre 1 et 100"<< endl;
cin >> a;
}
}
}
if (a>=61 && a<=80)
{
if (a==61)
{
n=50;
v=8;
b=5;
}
if (a==62)
{
n=100;
v=8;
b=5;
}
if (a==63)
{
n=200;
v=8;
b=5;
}
if (a==64)
{
n=500;
v=8;
b=5;
}
if (a==65)
{
n=1000;
v=12;
b=10;
}
if (a==66)
{
n=2000;
v=12;
b=10;
}
if (a==67)
{
n=5000;
v=12;
b=10;
}
if (a==68)
{
n=10000;
v=16;
b=15;
}
if (a==69)
{
n=25000;
v=16;
b=15;
}
if (a==70)
{
n=50000;
v=16;
b=15;
}
if (a==71)
{
n=100000;
v=20;
b=20;
}
if (a==72)
{
n=150000;
v=20;
b=20;
}
if (a==73)
{
n=200000;
v=25;
b=24;
}
if (a==74)
{
n=250000;
v=30;
b=24;
}
if (a==75)
{
n=500000;
v=35;
b=26;
}
if (a==76)
{
n=1000000;
v=40;
b=29;
}
if (a==77)
{
n=1500000;
v=50;
b=37;
}
if (a==78)
{
n=2000000;
v=60;
b=43;
}
if (a==79)
{
n=2500000;
v=80;
b=47;
}
if (a==80)
{
n=5000000;
v=100;
b=99;
}
t=v;
srand(time(NULL)); // initialisation du générateur, à appeler qu'une fois dans une application
//Qu'est-ce que c'est la fonction time( ) ?
x=rand(); // un nombre aléatoire est affecté à x, 0 <= x <= 0x7FFF
y=rand() % n+1;
cout << "Find the good number between 0 and " << n << endl << " Your number of propositions would be limited to " << t << endl << "At the end of each proposition, the number is increased by " << b << " !" << endl << "So the value change every times that you continue the game !" << endl << "In the end, the more is your score, the better is !" << endl;
cout << "Trouvez le bon nombre entre 0 et " << n << endl << " Votre nombre d'essai sera limite a " << t << " !" << endl <<"A la fin de chaque proposition, on rajoute " << b <<" au nombre a trouver !" << endl << "Donc sa valeur change au fur et a mesure que vous avancez !" << endl <<"A la fin, plus votre score est grand, mieux c'est !" << endl;
while (s!=y)
{
cout << "Tape a new proposition !"<<endl;
cout << "Tapez une nouvelle proposition !";
cin >> s;
if (s>y && t!=0)
{
cout << "It's less !"<< endl;
cout << "C'est moins !"<< endl;
t=t-1;
y=y+b;
cout << "It remains : " << t << " more propositions , retry !" << endl;
cout << "Il vous reste : " << t << " essais, recommencez !" << endl;
}
if (s<y && t!=0)
{
cout << "It's more !"<< endl;
cout << "C'est plus !"<< endl;
t=t-1;
y=y+b;
cout << "It remains : " << t << " more propositions , retry !" << endl;
cout << "Il vous reste : " << t << " essais, recommencez !" << endl;
}
if (t==0 && s!=y)
{
t=t-1;
cout <<"You've not found the good number in the number of propositions you've got at the beginning !" << endl;
cout <<"Vous n'avez pas trouve le bon numero dans le nombre d'essai qui vous etait imparti !" << endl;
cout <<"Would you like to restart the game ? o if yes, n if no" << endl;
cout <<"Souhaitez-vous recommencer ? o si oui, n si non";
cin >> z;
cout << "Choice a level difficulty between 1 and 100"<< endl;
cout << "Choisissez un niveau de difficulte entre 1 et 100"<< endl;
cin >> a;
}
if (s==y)
{
t=t-1;
cout <<"It's amazing ! You've found the good number ! That's your number of propositions : " << t << endl;
cout <<"Vous avez trouve le bon numero ! Voici donc votre nombre d'essai : " << t << endl;
cout <<"Score :" << t << "/" << v << endl;
cout <<"Would you like to restart the game ? o if yes, n if no" << endl;
cout <<"Souhaitez-vous recommencer ? o si oui, n si non";
cin >> z;
cout << "Choice a level difficulty between 1 and 100"<< endl;
cout << "Choisissez un niveau de difficulte entre 1 et 100"<< endl;
cin >> a;
}
}
}
if (a>=81 && a<=100)
{
if (a==81)
{
n=50;
v=8;
b=5;
}
if (a==82)
{
n=100;
v=8;
b=5;
}
if (a==83)
{
n=200;
v=8;
b=5;
}
if (a==84)
{
n=500;
v=8;
b=5;
}
if (a==85)
{
n=1000;
v=12;
b=10;
}
if (a==86)
{
n=2000;
v=12;
b=10;
}
if (a==87)
{
n=5000;
v=12;
b=10;
}
if (a==88)
{
n=10000;
v=16;
b=15;
}
if (a==89)
{
n=25000;
v=16;
b=15;
}
if (a==90)
{
n=50000;
v=16;
b=15;
}
if (a==91)
{
n=100000;
v=20;
b=20;
}
if (a==92)
{
n=150000;
v=20;
b=20;
}
if (a==93)
{
n=200000;
v=25;
b=24;
}
if (a==94)
{
n=250000;
v=30;
b=24;
}
if (a==95)
{
n=500000;
v=35;
b=26;
}
if (a==96)
{
n=1000000;
v=40;
b=29;
}
if (a==97)
{
n=1500000;
v=50;
b=37;
}
if (a==98)
{
n=2000000;
v=60;
b=43;
}
if (a==99)
{
n=2500000;
v=80;
b=47;
}
if (a==100)
{
n=5000000;
v=100;
b=99;
}
t=v;
srand(time(NULL)); // initialisation du générateur, à appeler qu'une fois dans une application
//Qu'est-ce que c'est la fonction time( ) ?
x=rand(); // un nombre aléatoire est affecté à x, 0 <= x <= 0x7FFF
y=rand() % n+1;
cout << "Find the good number between 0 and " << n << endl << " Your number of propositions would be limited to " << t << endl << "At the end of each proposition, the number is increased by " << b << " if your is over !" << endl << "And it decreased by " << b << " if your is under !" << endl << "So the value change every times that you continue the game !" << endl << "In the end, the more is your score, the better is !" << endl;
cout << "Trouvez le bon nombre entre 0 et " << n << endl << " Votre nombre d'essai sera limite a " << t << " !" << endl <<"A la fin de chaque proposition, on ajoute " << b <<" au nombre a trouver si votre nombre est superieur," << endl <<"et on enleve " << b <<" si votre nombre est inferieur !" << endl <<"Donc sa valeur change au fur et a mesure que vous avancez !" << endl <<"A la fin, plus votre score est grand, mieux c'est !" << endl;
while (s!=y)
{
cout << "Tape a new proposition !"<<endl;
cout << "Tapez une nouvelle proposition !";
cin >> s;
if (s>y && t!=0)
{
cout << "It's less !"<< endl;
cout << "C'est moins !"<< endl;
t=t-1;
y=y+b;
cout << "It remains : " << t << " more propositions , retry !" << endl;
cout << "Il vous reste : " << t << " essais, recommencez !" << endl;
}
if (s<y && t!=0)
{
cout << "It's more !"<< endl;
cout << "C'est plus !"<< endl;
t=t-1;
y=y-b;
cout << "It remains : " << t << " more propositions , retry !" << endl;
cout << "Il vous reste : " << t << " essais, recommencez !" << endl;
}
if (t==0 && s!=y)
{
t=t-1;
cout <<"You've not found the good number in the number of propositions you've got at the beginning !" << endl;
cout <<"Vous n'avez pas trouve le bon numero dans le nombre d'essai qui vous etait imparti !" << endl;
cout <<"Would you like to restart the game ? o if yes, n if no" << endl;
cout <<"Souhaitez-vous recommencer ? o si oui, n si non";
cin >> z;
cout << "Choice a level difficulty between 1 and 100"<< endl;
cout << "Choisissez un niveau de difficulte entre 1 et 100"<< endl;
cin >> a;
}
if (s==y)
{
t=t-1;
cout <<"It's amazing ! You've found the good number ! That's your number of propositions : " << t << endl;
cout <<"Vous avez trouve le bon numero ! Voici donc votre nombre d'essai : " << t << endl;
cout <<"Score :" << t << "/" << v << endl;
cout <<"Would you like to restart the game ? o if yes, n if no" << endl;
cout <<"Souhaitez-vous recommencer ? o si oui, n si non";
cin >> z;
cout << "Choice a level difficulty between 1 and 100"<< endl;
cout << "Choisissez un niveau de difficulte entre 1 et 100"<< endl;
cin >> a;
}
}
}
if (a>=101 && a<=200)
{
if (a==101)
{
n=50;
v=8;
b=5;
}
if (a==102)
{
n=100;
v=8;
b=5;
}
if (a==103)
{
n=200;
v=8;
b=5;
}
if (a==104)
{
n=500;
v=8;
b=5;
}
if (a==105)
{
n=1000;
v=12;
b=10;
}
if (a==106)
{
n=2000;
v=12;
b=10;
}
if (a==107)
{
n=5000;
v=12;
b=10;
}
if (a==108)
{
n=10000;
v=16;
b=15;
}
if (a==109)
{
n=25000;
v=16;
b=15;
}
if (a==110)
{
n=50000;
v=16;
b=15;
}
if (a==111)
{
n=100000;
v=20;
b=20;
}
if (a==112)
{
n=150000;
v=20;
b=20;
}
if (a==113)
{
n=200000;
v=25;
b=24;
}
if (a==114)
{
n=250000;
v=30;
b=24;
}
if (a==115)
{
n=500000;
v=35;
b=26;
}
if (a==116)
{
n=1000000;
v=40;
b=29;
}
if (a==117)
{
n=1500000;
v=50;
b=37;
}
if (a==118)
{
n=2000000;
v=60;
b=43;
}
if (a==119)
{
n=2500000;
v=80;
b=47;
}
if (a==120)
{
n=5000000;
v=100;
b=99;
}
if (a==121)
{
n=50;
v=7;
b=6;
}
if (a==122)
{
n=100;
v=7;
b=6;
}
if (a==123)
{
n=200;
v=7;
b=6;
}
if (a==124)
{
n=500;
v=7;
b=6;
}
if (a==125)
{
n=1000;
v=11;
b=11;
}
if (a==126)
{
n=2000;
v=11;
b=11;
}
if (a==127)
{
n=5000;
v=11;
b=11;
}
if (a==128)
{
n=10000;
v=15;
b=16;
}
if (a==129)
{
n=25000;
v=15;
b=16;
}
if (a==130)
{
n=50000;
v=15;
b=16;
}
if (a==131)
{
n=100000;
v=19;
b=21;
}
if (a==132)
{
n=150000;
v=19;
b=21;
}
if (a==133)
{
n=200000;
v=24;
b=25;
}
if (a==134)
{
n=250000;
v=29;
b=25;
}
if (a==135)
{
n=500000;
v=34;
b=27;
}
if (a==136)
{
n=1000000;
v=39;
b=30;
}
if (a==137)
{
n=1500000;
v=49;
b=38;
}
if (a==138)
{
n=2000000;
v=59;
b=44;
}
if (a==139)
{
n=2500000;
v=79;
b=48;
}
if (a==140)
{
n=5000000;
v=99;
b=100;
}
if (a==141)
{
n=50;
v=8;
b=10;
}
if (a==142)
{
n=100;
v=8;
b=10;
}
if (a==143)
{
n=200;
v=8;
b=10;
}
if (a==144)
{
n=500;
v=8;
b=10;
}
if (a==145)
{
n=1000;
v=12;
b=20;
}
if (a==146)
{
n=2000;
v=12;
b=20;
}
if (a==147)
{
n=5000;
v=12;
b=20;
}
if (a==148)
{
n=10000;
v=16;
b=30;
}
if (a==149)
{
n=25000;
v=16;
b=30;
}
if (a==150)
{
n=50000;
v=16;
b=30;
}
if (a==151)
{
n=100000;
v=20;
b=40;
}
if (a==152)
{
n=150000;
v=20;
b=40;
}
if (a==153)
{
n=200000;
v=25;
b=48;
}
if (a==154)
{
n=250000;
v=30;
b=48;
}
if (a==155)
{
n=500000;
v=35;
b=52;
}
if (a==156)
{
n=1000000;
v=40;
b=58;
}
if (a==157)
{
n=1500000;
v=50;
b=74;
}
if (a==158)
{
n=2000000;
v=60;
b=86;
}
if (a==159)
{
n=2500000;
v=80;
b=94;
}
if (a==160)
{
n=5000000;
v=100;
b=198;
}
if (a==161)
{
n=50;
v=18;
b=50;
}
if (a==162)
{
n=100;
v=18;
b=50;
}
if (a==163)
{
n=200;
v=18;
b=50;
}
if (a==164)
{
n=500;
v=18;
b=50;
}
if (a==165)
{
n=1000;
v=22;
b=100;
}
if (a==166)
{
n=2000;
v=22;
b=100;
}
if (a==167)
{
n=5000;
v=22;
b=100;
}
if (a==168)
{
n=10000;
v=26;
b=150;
}
if (a==169)
{
n=25000;
v=26;
b=150;
}
if (a==170)
{
n=50000;
v=26;
b=150;
}
if (a==171)
{
n=100000;
v=30;
b=200;
}
if (a==172)
{
n=150000;
v=30;
b=200;
}
if (a==173)
{
n=200000;
v=35;
b=240;
}
if (a==174)
{
n=250000;
v=40;
b=240;
}
if (a==175)
{
n=500000;
v=45;
b=260;
}
if (a==176)
{
n=1000000;
v=50;
b=290;
}
if (a==177)
{
n=1500000;
v=60;
b=370;
}
if (a==178)
{
n=2000000;
v=70;
b=430;
}
if (a==179)
{
n=2500000;
v=90;
b=470;
}
if (a==180)
{
n=5000000;
v=110;
b=990;
}
if (a==181)
{
n=50;
v=100;
b=50;
}
if (a==182)
{
n=100;
v=100;
b=100;
}
if (a==183)
{
n=200;
v=100;
b=200;
}
if (a==184)
{
n=500;
v=100;
b=500;
}
if (a==185)
{
n=1000;
v=100;
b=1000;
}
if (a==186)
{
n=2000;
v=100;
b=2000;
}
if (a==187)
{
n=5000;
v=100;
b=5000;
}
if (a==188)
{
n=10000;
v=100;
b=10000;
}
if (a==189)
{
n=25000;
v=100;
b=25000;
}
if (a==190)
{
n=50000;
v=100;
b=50000;
}
if (a==191)
{
n=100000;
v=100;
b=100000;
}
if (a==192)
{
n=150000;
v=100;
b=150000;
}
if (a==193)
{
n=200000;
v=100;
b=200000;
}
if (a==194)
{
n=250000;
v=100;
b=250000;
}
if (a==195)
{
n=500000;
v=100;
b=500000;
}
if (a==196)
{
n=1000000;
v=100;
b=1000000;
}
if (a==197)
{
n=1500000;
v=100;
b=1500000;
}
if (a==198)
{
n=2000000;
v=100;
b=2000000;
}
if (a==199)
{
n=2500000;
v=100;
b=2500000;
}
if (a==200)
{
n=5000000;
v=100;
b=5000000;
}
t=v;
srand(time(NULL)); // initialisation du générateur, à appeler qu'une fois dans une application
//Qu'est-ce que c'est la fonction time( ) ?
x=rand(); // un nombre aléatoire est affecté à x, 0 <= x <= 0x7FFF
y=rand() % n+1;
cout << "Find the good number between 0 and " << n << endl << " Your number of propositions would be limited to " << t << endl << "At the end of each proposition, the number is increased by a number under or equal to " << b << " if your is over !" << endl << "And it decreased by under or equal to " << b << " if your is under !" << endl << "So the value change every times that you continue the game !" << endl << "In the end, the more is your score, the better is !" << endl;
cout << "Trouvez le bon nombre entre 0 et " << n << endl << " Votre nombre d'essai sera limite a " << t << " !" << endl <<"A la fin de chaque proposition, on peut ajouter jusqu'à " << b <<" au nombre a trouver si votre nombre est superieur," << endl <<"et on peut enlever jusqu'à " << b <<" si votre nombre est inferieur !" << endl <<"Donc sa valeur change au fur et a mesure que vous avancez !" << endl <<"A la fin, plus votre score est grand, mieux c'est !" << endl;
while (s!=y)
{
cout << "Tape a new proposition !"<<endl;
cout << "Tapez une nouvelle proposition !";
cin >> s;
if (s>y && t!=0)
{
cout << "It's less !"<< endl;
cout << "C'est moins !"<< endl;
t=t-1;
w=rand() % b+1;
y=y+w;
cout << "It remains : " << t << " more propositions , retry !" << endl;
cout << "Il vous reste : " << t << " essais, recommencez !" << endl;
}
if (s<y && t!=0)
{
cout << "It's more !"<< endl;
cout << "C'est plus !"<< endl;
t=t-1;
w=rand() % b+1;
y=y-w;
cout << "It remains : " << t << " more propositions , retry !" << endl;
cout << "Il vous reste : " << t << " essais, recommencez !" << endl;
}
if (t==0 && s!=y)
{
t=t-1;
cout <<"You've not found the good number in the number of propositions you've got at the beginning !" << endl;
cout <<"Vous n'avez pas trouve le bon numero dans le nombre d'essai qui vous etait imparti !" << endl;
cout <<"Would you like to restart the game ? o if yes, n if no" << endl;
cout <<"Souhaitez-vous recommencer ? o si oui, n si non";
cin >> z;
cout << "Choice a level difficulty between 1 and 100"<< endl;
cout << "Choisissez un niveau de difficulte entre 1 et 100"<< endl;
cin >> a;
}
if (s==y)
{
t=t-1;
cout <<"It's really amazing ! You've found the good number ! That's your number of propositions : " << t << endl;
cout <<"Vous avez trouve le bon numero ! Voici donc votre nombre d'essai : " << t << endl;
cout <<"Score :" << t << "/" << v << endl;
cout <<"Would you like to restart the game ? o if yes, n if no" << endl;
cout <<"Souhaitez-vous recommencer ? o si oui, n si non";
cin >> z;
cout << "Choice a level difficulty between 1 and 100"<< endl;
cout << "Choisissez un niveau de difficulte entre 1 et 100"<< endl;
cin >> a;
}
}
}
}
if (z=='n')
{
cout << "Bye !" << endl;
}
getch();
}

2 réponses

lural Messages postés 131 Date d'inscription samedi 6 janvier 2007 Statut Membre Dernière intervention 4 janvier 2011 2
9 déc. 2009 à 19:51
Salut,

Niveau 101 : Score :5/8
Niveau 150 : Score :53/100

Sinon, le code est pas très très beau
Un exemple :
if (a==2)
{
n=100;
}
if (a==3)
{
n=200;
}
if (a==4)
{
n=500;
}
if (a==5)
{
n=1000;
}
if (a==6)
{
n=2000;
}
if (a==7)
{
n=5000;
}
if (a==8)
{
n=10000;
}
if (a==9)
{

A tranformer en
switch(a){
case 2: n=100; break;
case 3: n=200; break;
...


ou beaucoup mieux en
valN[0, 50, 100, 200, 500, 1000...
n=valN[a];


Et puis fais des fonctions au lieu de répéter ton code plusieurs fois ;)

Bye
0
lural Messages postés 131 Date d'inscription samedi 6 janvier 2007 Statut Membre Dernière intervention 4 janvier 2011 2
9 déc. 2009 à 19:54
Houla pardon,
valN[0, 50, 100, 200, 500, 1000...

devient bien sur
int valN[]={0, 50, 100, 200, 500, 1000...};
0
Rejoignez-nous