l4.c 675 B

123456789101112131415161718192021222324252627282930313233
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. int main() {
  5. srand(time(NULL));
  6. int x = rand() % 11;
  7. int s = 0;
  8. while(1) {
  9. int pol;
  10. printf("Number ");
  11. scanf("%d", &pol);
  12. if(pol == x) {
  13. printf("the number is guessed\n");
  14. break;
  15. }
  16. else {
  17. printf("the number is not guessed\n");
  18. if(pol > x) {
  19. printf("less\n");
  20. }
  21. else {
  22. printf("more\n");
  23. }
  24. s++;
  25. if(s == 3) {
  26. printf("Game over\n");
  27. break;
  28. }
  29. }
  30. }
  31. return 0;
  32. }