Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <Windows.h>
  3. #include <stdio.h>
  4. #include <malloc.h>
  5.  
  6. int main()
  7. {
  8. SetConsoleCP(1251);
  9. SetConsoleOutputCP(1251);
  10.  
  11. int x0,y0, bomb, n, turn = 0;
  12. int** mas;
  13. char bomb_dir[2] = "2";
  14. printf("Введите количество клеток\n");
  15. scanf("%d", &n);
  16. mas = (int**)malloc(sizeof(int*) * n);
  17. for (int i = 0; i < n; i++)
  18. {
  19. mas[i] = (int*)malloc(sizeof(int) * n);
  20. }
  21. x0 = rand() % n;
  22. y0 = rand() % n;
  23. getchar();
  24. while (bomb_dir[0] != 'W' || bomb_dir[1] != 'W')
  25. {
  26. printf("Местоположение бэтмена: %d %d\n", x0, y0);
  27. printf("Местоположение бомбы\n");
  28. fflush(stdin);
  29. scanf_s("%c", &bomb_dir);
  30. getchar();
  31. if (bomb_dir[0] == 'U' || bomb_dir[1] == 'U')
  32. {
  33. y0 = y0 / 2;
  34. }
  35. if (bomb_dir[0] == 'D' || bomb_dir[1] == 'D')
  36. {
  37. y0 = (y0 + n) / 2;
  38. }
  39. if (bomb_dir[0] == 'L' || bomb_dir[1] == 'L')
  40. {
  41. x0 = x0 / 2;
  42. }
  43. if (bomb_dir[0] == 'R' || bomb_dir[1] == 'R')
  44. {
  45. x0 = (x0 + n) / 2;
  46. }
  47. if (strcmp(bomb_dir,"UR") == 0);
  48. {
  49. x0 = (x0 + n) / 2;
  50. y0 = y0 / 2;
  51. }
  52. if (strcmp(bomb_dir, "DR") == 0)
  53. {
  54. x0 = x0 / 2;
  55. y0 = y0 / 2;
  56. }
  57. if (strcmp(bomb_dir, "DL") == 0)
  58. {
  59. x0 = x0 / 2;
  60. y0 = (y0 + n) / 2;
  61. }
  62. if (strcmp(bomb_dir, "UL") == 0)
  63. {
  64. x0 = (x0 + n) / 2;
  65.  
  66. y0 = (y0 + n) / 2;
  67. }
  68. turn++;
  69. }
  70. printf("Количество ходов: %d", turn);
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement