Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Little Game (More or Less) in C
#1
There you go, it's a little game called more or less..

Tell me what you think Smile

Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>


int main()
{
int MAX = 100, MIN = 1;
int nombreMystere;
int nombreDuJoueur=0;
int compteur=0;
int partie=1;
int joueur;
int choixNiveau=1;

srand(time(NULL));


while (partie)//Tant que partie est égale à 1
{
    printf("\n\n*** MORE OR LESS GAME ***\n\n");
    printf("You want to play 1 or 2 players? : ");
    scanf("%d",&joueur);
                    if (joueur==1)
                    {
                        printf("\n\nEnter a difficulty level:\n");
                        printf("1. Between 0 et 100\n");
                        printf("2. Between 1 et 1 000\n");
                        printf("3. Between 1 et 10 000\n");
                        printf("Your choice : ");
                        scanf("%d",&choixNiveau);

                            switch (choixNiveau)
                            {
                            case 1:
                            MAX=100;
                            break;
                            case 2:
                            MAX=1000;
                            break;
                            case 3:
                            MAX=10000;
                            break;
                            default:
                            printf("\n\nYour choice is not permitted so it will be Level 1\n\n");
                            MAX=100;
                            break;
                            }

    nombreMystere = (rand() % (MAX - MIN + 1)) + MIN;
    compteur=0;
    while(nombreMystere != nombreDuJoueur)
    {
        printf("What is the number ? ");
        scanf("%d",&nombreDuJoueur);
        compteur++;

        if (nombreDuJoueur<nombreMystere)
            {
                printf("\nIt's more !\n");
            }
        else if (nombreDuJoueur > nombreMystere)
            {
                printf("\nIt's less !\n");
            }
        else
            {
                printf("\n\nCongratulations, you have found the mystery number in %d its !!!\n\n",compteur);
                printf("Another game ? (1 for yes/ 0 for no)");
                scanf("%d",&partie);
            }
    }
                        }

                        else if (joueur==2)
                        {
    printf("\n\nPlayer 1, enter the number that player 2 will have to find : ");
    nombreMystere=0;
    compteur=0;
    scanf("%d",&nombreMystere);
    printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
    while(nombreMystere != nombreDuJoueur)
    {

        printf("Player 2 : Which number player 1 has to guess ? ");
        scanf("%d",&nombreDuJoueur);
        compteur++;

        if (nombreDuJoueur<nombreMystere)
            {
                printf("\n It's more !\n");
            }
        else if (nombreDuJoueur > nombreMystere)
            {
                printf("\It's less!\n");
            }
        else
            {
                printf("\n\nCongratulations player 2, you have found the mystery number in %d hits !!!\n\n",compteur);
                printf("Another game? ? (1 for yes / 0 for no)");
                scanf("%d",&partie);
            }
    }

                        }
else

{
printf("We asked 1 or 2 players nothing else! ");
}

}
    return 0;
}
[Image: f_pgfbb4em_bde9974.png]
Reply
#2
I like it !
But when u win it says you won in 15 its not hits lol
Reply
#3
What do you mean?
[Image: f_pgfbb4em_bde9974.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)