50 lines
719 B
C
50 lines
719 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "guesser.h"
|
|
|
|
#define MAX_TRIES 10
|
|
|
|
int main()
|
|
{
|
|
printf("Guess the number between 1 and 100:\n");
|
|
|
|
int number = guess_number(1, 100);
|
|
|
|
int user_guess;
|
|
int tries = 0;
|
|
|
|
do
|
|
{
|
|
printf("%d tries left. Guess: ", MAX_TRIES - tries);
|
|
scanf("%d", &user_guess);
|
|
|
|
if (abs(user_guess - number) < 10)
|
|
{
|
|
printf("You're close\n");
|
|
}
|
|
|
|
if (user_guess > number)
|
|
{
|
|
printf("A bit lower\n");
|
|
tries++;
|
|
}
|
|
else if (user_guess < number)
|
|
{
|
|
printf("A bit highter\n");
|
|
tries++;
|
|
}
|
|
}
|
|
while (number != user_guess && tries < MAX_TRIES);
|
|
|
|
if (tries == MAX_TRIES)
|
|
{
|
|
printf("You lost :(\n");
|
|
}
|
|
else
|
|
{
|
|
printf("You won! Good job :)\n");
|
|
}
|
|
|
|
return 0;
|
|
}
|