Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int main(int argc, char *argv[])
- {
- const int MAX=100,MIN=1;
- int choix=0, nombre=0, compteur=0, game=0, player=0;
- srand(time(NULL));
- do
- {
- compteur=0;
- do
- {
- printf("\nVoulez vous jouer a 1 ou 2 joueurs ?\n");
- scanf("%d",&player);
- switch (player)
- {
- case 1:
- nombre = (rand() % (MAX - MIN + 1)) + MIN;
- break;
- case 2:
- printf("\nJoueur 1, rentrez la valeur a trouver\n");
- scanf("%d",&nombre);
- break;
- default:
- printf("mauvaise reponse veuillez recomencer");
- break;
- }
- } while(player!=1||player!=2);
- do
- {
- printf("Entrez un nombre et appuyez sur entre\n\n");
- scanf("%d",&choix);
- compteur++;
- if (choix>nombre)
- printf("\n\nTrop grand\n\n");
- else if(choix<nombre)
- printf("\n\nTrop petit\n\n");
- else
- break;
- }while (choix!=nombre);
- printf("\n\nFelicitations vous avez reussi apres %d essais",compteur);
- printf("\n\nVoulez vous rejouer ?\n1. Oui\n2.Non\n");
- scanf("%d",&game);
- }while (game==1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement