update l4.c
This commit is contained in:
parent
e3dbc13e9a
commit
69107ea260
2 changed files with 12 additions and 2 deletions
14
c/l4.c
14
c/l4.c
|
|
@ -1,17 +1,27 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
int main() {
|
||||
int x = 7;
|
||||
srand(time(NULL));
|
||||
int x = rand() % 11;
|
||||
int s = 0;
|
||||
while(1) {
|
||||
int pol;
|
||||
printf("Number ");
|
||||
scanf("%d", &pol);
|
||||
if(pol == 7) {
|
||||
if(pol == x) {
|
||||
printf("the number is guessed\n");
|
||||
break;
|
||||
}
|
||||
else {
|
||||
printf("the number is not guessed\n");
|
||||
if(pol > x) {
|
||||
printf("less\n");
|
||||
}
|
||||
else {
|
||||
printf("more\n");
|
||||
}
|
||||
s++;
|
||||
if(s == 3) {
|
||||
printf("Game over\n");
|
||||
|
|
|
|||
0
c/l5.c
Normal file
0
c/l5.c
Normal file
Loading…
Reference in a new issue