Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <Windows.h>
- #include <stdio.h>
- #include <malloc.h>
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- int x0,y0, bomb, n, turn = 0;
- int** mas;
- char bomb_dir[2] = "2";
- printf("Введите количество клеток\n");
- scanf("%d", &n);
- mas = (int**)malloc(sizeof(int*) * n);
- for (int i = 0; i < n; i++)
- {
- mas[i] = (int*)malloc(sizeof(int) * n);
- }
- x0 = rand() % n;
- y0 = rand() % n;
- getchar();
- while (bomb_dir[0] != 'W' || bomb_dir[1] != 'W')
- {
- printf("Местоположение бэтмена: %d %d\n", x0, y0);
- printf("Местоположение бомбы\n");
- fflush(stdin);
- scanf_s("%c", &bomb_dir);
- getchar();
- if (bomb_dir[0] == 'U' || bomb_dir[1] == 'U')
- {
- y0 = y0 / 2;
- }
- if (bomb_dir[0] == 'D' || bomb_dir[1] == 'D')
- {
- y0 = (y0 + n) / 2;
- }
- if (bomb_dir[0] == 'L' || bomb_dir[1] == 'L')
- {
- x0 = x0 / 2;
- }
- if (bomb_dir[0] == 'R' || bomb_dir[1] == 'R')
- {
- x0 = (x0 + n) / 2;
- }
- if (strcmp(bomb_dir,"UR") == 0);
- {
- x0 = (x0 + n) / 2;
- y0 = y0 / 2;
- }
- if (strcmp(bomb_dir, "DR") == 0)
- {
- x0 = x0 / 2;
- y0 = y0 / 2;
- }
- if (strcmp(bomb_dir, "DL") == 0)
- {
- x0 = x0 / 2;
- y0 = (y0 + n) / 2;
- }
- if (strcmp(bomb_dir, "UL") == 0)
- {
- x0 = (x0 + n) / 2;
- y0 = (y0 + n) / 2;
- }
- turn++;
- }
- printf("Количество ходов: %d", turn);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement