#include<stdio.h>                       //ÀîÃ÷Ç«
#include<stdlib.h>

void GuessNumber (int magic, int counter, int guess, int a, int num)
{
	char b;
    printf("Please guess a magic number:\n");
	while(counter++)
   {
            a++;
            scanf("%d", &guess);
            if (guess > magic && counter <= 7)
            {
                printf("Bigger than the answer, guess again:\n");
            }
            else if (guess < magic && counter <= 7)
            {
                printf("Smaller than the answer, guess again:\n");
            }
            else if (guess == magic && counter <= 7)
            {
                printf("Correct!\n");
				return;
            }
            else if (counter == 8 && guess != magic)
            {
                if ((a/8) < num)
                {
                    counter = 1;
                    a++;
                    printf("Please guess a magic number:\n");
                }
                else
                {
                    printf("You fail the game.\n");
                    return;
                }
            }
   }
}

int main()
{
    int magic, counter = 1, guess = 0, num, a = 1;
    unsigned int seed;
    printf("During this game, the number is between 0 and 100.You have 7 chances each round.\n");
    printf("please enter seed and the number you want to play:\n");
    scanf("%u %d", &seed, &num);
    srand (seed);
    magic = rand() % 101;
    GuessNumber(magic, counter, guess, a, num);

    return 0;
}
