my/c/l4.c

33 lines
675 B
C
Raw Permalink Normal View History

2026-05-07 14:48:02 +03:00
#include <stdio.h>
2026-05-07 19:07:58 +03:00
#include <stdlib.h>
#include <time.h>
2026-05-07 14:48:02 +03:00
int main() {
2026-05-07 19:07:58 +03:00
srand(time(NULL));
int x = rand() % 11;
2026-05-07 14:48:02 +03:00
int s = 0;
while(1) {
int pol;
printf("Number ");
scanf("%d", &pol);
2026-05-07 19:07:58 +03:00
if(pol == x) {
2026-05-07 14:48:02 +03:00
printf("the number is guessed\n");
break;
}
else {
printf("the number is not guessed\n");
2026-05-07 19:07:58 +03:00
if(pol > x) {
printf("less\n");
}
else {
printf("more\n");
}
2026-05-07 14:48:02 +03:00
s++;
if(s == 3) {
printf("Game over\n");
break;
}
}
}
return 0;
}