-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path16.c
40 lines (33 loc) · 893 Bytes
/
16.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int radomnumber, guess, times = 0;
srand(time(0));
radomnumber = rand() % 100 + 1;
printf("there is a number between 1 with 100, can you guess?\n");
do
{
scanf("%d", &guess);
times++;
if (guess == radomnumber)
{
printf("congratulations to you ! you had totally guessed %d times.\n", times);
}
else if (guess < radomnumber)
{
printf("it's too small , please try again.\n");
}
else if (guess > radomnumber)
{
printf("it's too big , please try again.\n");
}
else
{
printf("something wrong happened , please try again.\n");
}
}
while (guess != radomnumber);
return 0;
}