74 lines
1.8 KiB
C
74 lines
1.8 KiB
C
#include<stdio.h>
|
|
|
|
enum NIVEAU {TRES_FACILE, FACILE, DIFFICILE, TRES_DIFFICILE, EXPERT, INDEFINI};
|
|
|
|
enum NIVEAU demanderNiveau(){
|
|
char choix;
|
|
printf("Bienvenue au Koikecélenombre !\n"
|
|
"Sélectionnez votre NIVEAU (je ne comprends pas le SNAKE_CASE)\n"
|
|
"1: très facile\n"
|
|
"2: facile\n"
|
|
"3: difficile\n"
|
|
"4: très difficile\n"
|
|
"5: expert\n"
|
|
"q: quitter l'application\n"
|
|
"Votre choix : ");
|
|
scanf("%c", &choix);getchar();
|
|
switch(choix){
|
|
case '1':
|
|
return TRES_FACILE;
|
|
case '2':
|
|
return FACILE;
|
|
case '3':
|
|
return DIFFICILE;
|
|
case '4':
|
|
return TRES_DIFFICILE;
|
|
case '5':
|
|
return EXPERT;
|
|
default:
|
|
return INDEFINI;
|
|
}
|
|
|
|
}
|
|
|
|
int main() {
|
|
int nmax;
|
|
int ndevine;
|
|
int nprop;
|
|
|
|
enum NIVEAU niv;
|
|
while(1){
|
|
niv = demanderNiveau();
|
|
switch(niv){
|
|
case TRES_FACILE:
|
|
nmax=10;break;
|
|
case FACILE:
|
|
nmax=20;break;
|
|
case DIFFICILE:
|
|
nmax=50;break;
|
|
case TRES_DIFFICILE:
|
|
nmax=100;break;
|
|
case EXPERT:
|
|
nmax=500;break;
|
|
default:
|
|
return 0;
|
|
}
|
|
do{
|
|
printf("Ami, donnez votre nombre : ");
|
|
scanf("%d", &ndevine);
|
|
}while(nmax<ndevine || 1>ndevine);
|
|
|
|
//for(int i=0; i<420; i++){printf("\n");}
|
|
nprop=0;
|
|
printf("\033[2JMaintenant, joueur, faites vos propositions.\n");
|
|
for(int j=1; nprop!=ndevine; j++){
|
|
printf("Je pense que c'est le ");
|
|
scanf("%d", &nprop);
|
|
if(nprop<ndevine)printf("C'est plus.\n");
|
|
else if(ndevine<nprop)printf("C'est moins.\n");
|
|
else printf("C'est ça !\nFélicitations, tu as trouvé en %d propositions.\n",j);
|
|
}
|
|
|
|
}
|
|
}
|