Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <string.h>
- #define WindowsVista
- int main()
- {
- char rejouer[100];
- char vrai[] = "oui";
- do
- {
- int demande = 0;
- int coups = 0;
- int nombreDeJoueurs = 1;
- srand(time(NULL));
- printf("Nombre de Joueurs : ");
- scanf("%d", &nombreDeJoueurs);
- if(nombreDeJoueurs == 1)
- {
- char difficultee[100];
- char facile[] = "facile";
- char moyen[] = "moyen";
- char difficile[] = "difficile";
- char expert[] = "expert";
- char legendaire[] = "legendaire";
- printf("Niveau de difficultee :\n");
- printf("- facile\n");
- printf("- moyen\n");
- printf("- difficile\n");
- printf("- expert\n");
- printf("- legendaire\n\n");
- scanf("%s", difficultee);
- #ifdef WindowsVista
- system("cls");
- #endif // WindowsVista
- #ifdef Linux
- system("clear");
- #endif // Linux
- if(strcmp(difficultee, facile) == 0)
- {
- const int MAX = 100, MIN = 0;
- int aleatoire = (rand() % (MAX - MIN + 1) + MIN);
- do
- {
- coups = coups + 1;
- printf("Entrer un nombre : ");
- scanf("%d", &demande);
- if(demande < aleatoire)
- {
- printf("C\'est plus !\n");
- }
- else if(demande > aleatoire)
- {
- printf("C\'est moins !\n");
- }
- else
- {
- printf("Vous avez gagner en %d coups\n\n", coups);
- }
- }while(demande != aleatoire);
- }
- else if(strcmp(difficultee, moyen) == 0)
- {
- const int MAX = 1000, MIN = 0;
- int aleatoire = (rand() % (MAX - MIN + 1) + MIN);
- do
- {
- coups = coups + 1;
- printf("Entrer un nombre :");
- scanf("%d", &demande);
- if(demande < aleatoire)
- {
- printf("C\'est plus !\n");
- }
- else if(demande > aleatoire)
- {
- printf("C\'est moins !\n");
- }
- else
- {
- printf("Vous avez gagner en %d coups\n\n", coups);
- }
- }while(demande != aleatoire);
- }
- else if(strcmp(difficultee, difficile) == 0)
- {
- const int MAX = 10000, MIN = 0;
- int aleatoire = (rand() % (MAX - MIN + 1) + MIN);
- do
- {
- coups = coups + 1;
- printf("Entrer un nombre :");
- scanf("%d", &demande);
- if(demande < aleatoire)
- {
- printf("C\'est plus !\n");
- }
- else if(demande > aleatoire)
- {
- printf("C\'est moins !\n");
- }
- else
- {
- printf("Vous avez gagner en %d coups\n\n", coups);
- }
- }while(demande != aleatoire);
- }
- else if(strcmp(difficultee, expert) == 0)
- {
- const int MAX = 10000, MIN = -10000;
- int aleatoire = (rand() % (MAX - MIN + 1) + MIN);
- do
- {
- coups = coups + 1;
- printf("Entrer un nombre :");
- scanf("%d", &demande);
- if(demande < aleatoire)
- {
- printf("C\'est plus !\n");
- }
- else if(demande > aleatoire)
- {
- printf("C\'est moins !\n");
- }
- else
- {
- printf("Vous avez gagner en %d coups\n\n", coups);
- }
- }while(demande != aleatoire);
- }
- else if(strcmp(difficultee, legendaire) == 0)
- {
- long demande = 0;
- const long MAX = 1000000, MIN = -1000000;
- long aleatoire = (rand() % (MAX - MIN + 1) + MIN);
- do
- {
- coups = coups + 1;
- printf("Entrer un nombre :");
- scanf("%ld", &demande);
- if(demande < aleatoire)
- {
- printf("C\'est plus !\n");
- }
- else if(demande > aleatoire)
- {
- printf("C\'est moins !\n");
- }
- else
- {
- printf("Vous avez gagner en %d coups\n\n", coups);
- }
- }while(demande != aleatoire);
- }
- }
- else if(nombreDeJoueurs == 2)
- {
- int mystere;
- printf("Joueur 1 : Entrer le nombre mystere : ");
- scanf("%d", &mystere);
- #ifdef WindowsVista
- system("cls");
- #endif // WindowsVista
- #ifdef Linux
- system("clear");
- #endif // Linux
- do
- {
- coups = coups + 1;
- printf("Joueur 2 : Entrer un nombre : ");
- scanf("%d", &demande);
- if(demande < mystere)
- {
- printf("C\'est plus !\n");
- }
- else if(demande > mystere)
- {
- printf("C\'est moins !\n");
- }
- else
- {
- printf("Vous avez gagner en %d coups\n\n", coups);
- }
- }while(demande != mystere);
- }
- printf("Voulez-vous rejouer ?\n");
- printf("- oui\n");
- printf("- non\n\n");
- scanf("%s", rejouer);
- #ifdef WindowsVista
- if(strcmp(rejouer, vrai) == 0)
- {
- system("cls");
- }
- #endif // WindowsVista
- #ifdef Linux
- if(strcmp(rejouer, vrai) == 0)
- {
- system("clear");
- }
- #endif // Linux
- }while(strcmp(rejouer, vrai) == 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement