Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <stdlib.h>
- #include <stdio.h>
- int main() {
- char Lab[12][12] = {
- { '#','#','#','#','#','#','#','#','#','#','#','#' },
- { '#','#','#','#','#','#','#','#','#',' ','*','#' },
- { '#','#','#','#','#','#','#','#','#',' ','#','#' },
- { '#','#','#','#','#','#',' ','#','#',' ',' ','#' },
- { '#','#','#','#','#','#',' ',' ',' ',' ','#','#' },
- { '#',' ',' ','#',' ',' ',' ',' ','#','#','#','#' },
- { '#','#',' ','#',' ','#','#','#','#','#','#','#' },
- { '#','#',' ',' ',' ','#','#','#','#','#','#','#' },
- { '#','#',' ','#','#','#','#',' ',' ',' ','#','#' },
- { '#','#',' ',' ',' ','#','#',' ','#',' ','#','#' },
- { '#','#','#','#',' ',' ',' ',' ','#','@','#','#' },
- { '#','#','#','#','#','#','#','#','#','#','#','#' }
- };
- int x = 0;
- int y = 0;
- char d = 'u';
- for (int i = 0; i < 12; i++) {
- for (int j = 0; j < 12; j++) {
- if (Lab[i][j] == '*') {
- y = i;
- x = j;
- };
- };
- };
- while (Lab[y][x] != '@') {
- if (Lab[y + 1][x] == '@' || Lab[y - 1][x] == '@' || Lab[y][x + 1] == '@' || Lab[y][x - 1] == '@') { Lab[y][x] = '@'; }
- if (d == 'u') {
- while (Lab[y - 1][x] == ' ' && Lab[y][x + 1] == '#') {
- y--;
- Lab[y][x] = '*';
- Lab[y + 1][x] = ' ';
- Sleep(50);
- system("cls");
- for (int i = 0; i < 12; i++) {
- for (int j = 0; j < 12; j++) {
- printf("%c ",Lab[i][j]);
- };
- printf("\n");
- };
- }
- if (Lab[y][x + 1] == ' ') {
- d = 'r'; x++; Lab[y][x] = '*'; Lab[y][x - 1] = ' ';
- Sleep(100);
- system("cls");
- for (int i = 0; i < 12; i++) {
- for (int j = 0; j < 12; j++) {
- printf("%c ", Lab[i][j]);
- };
- printf("\n");
- }
- }
- else if (Lab[y][x - 1] == ' ') {
- d = 'l'; x--; Lab[y][x] = '*'; Lab[y][x + 1] = ' ';
- Sleep(50);
- system("cls");
- for (int i = 0; i < 12; i++) {
- for (int j = 0; j < 12; j++) {
- printf("%c ", Lab[i][j]);
- };
- printf("\n");
- };
- }
- else { d = 'd'; }
- }
- else if (d == 'r') {
- while (Lab[y][x + 1] == ' ' && Lab[y + 1][x] == '#') {
- x++;
- Lab[y][x] = '*';
- Lab[y][x - 1] = ' ';
- Sleep(50);
- system("cls");
- for (int i = 0; i < 12; i++) {
- for (int j = 0; j < 12; j++) {
- printf("%c ", Lab[i][j]);
- };
- printf("\n");
- };
- }
- if (Lab[y + 1][x] == ' ') {
- d = 'd'; y++; Lab[y][x] = '*'; Lab[y - 1][x] = ' ';
- Sleep(50);
- system("cls");
- for (int i = 0; i < 12; i++) {
- for (int j = 0; j < 12; j++) {
- printf("%c ", Lab[i][j]);
- };
- printf("\n");
- };
- }
- else if (Lab[y - 1][x] == ' ') {
- d = 'u'; y--; Lab[y][x] = '*'; Lab[y + 1][x] = ' ';
- Sleep(50);
- system("cls");
- for (int i = 0; i < 12; i++) {
- for (int j = 0; j < 12; j++) {
- printf("%c ", Lab[i][j]);
- };
- printf("\n");
- };
- }
- else { d = 'l'; }
- }
- else if (d == 'd') {
- while (Lab[y + 1][x] == ' ' && Lab[y][x - 1] == '#') {
- y++;
- Lab[y][x] = '*';
- Lab[y - 1][x] = ' ';
- Sleep(50);
- system("cls");
- for (int i = 0; i < 12; i++) {
- for (int j = 0; j < 12; j++) {
- printf("%c ", Lab[i][j]);
- };
- printf("\n");
- };
- }
- if (Lab[y][x - 1] == ' ') {
- d = 'l'; x--; Lab[y][x] = '*'; Lab[y][x + 1] = ' ';
- Sleep(50);
- system("cls");
- for (int i = 0; i < 12; i++)
- {
- for (int j = 0; j < 12; j++) {
- printf("%c ", Lab[i][j]);
- };
- printf("\n");
- };
- }
- else if (Lab[y][x + 1] == ' ') {
- d = 'r'; x++; Lab[y][x] = '*'; Lab[y][x - 1] = ' ';
- Sleep(50);
- system("cls");
- for (int i = 0; i < 12; i++) {
- for (int j = 0; j < 12; j++) {
- printf("%c ", Lab[i][j]);
- };
- printf("\n");
- };
- }
- else { d = 'u'; }
- }
- else if (d == 'l') {
- while (Lab[y][x - 1] == ' ' && Lab[y - 1][x] == '#') {
- x--;
- Lab[y][x] = '*';
- Lab[y][x + 1] = ' ';
- Sleep(50);
- system("cls");
- for (int i = 0; i < 12; i++) {
- for (int j = 0; j < 12; j++) {
- printf("%c ", Lab[i][j]);
- };
- printf("\n");
- };
- }
- if (Lab[y - 1][x] == ' ') {
- d = 'u'; y--; Lab[y][x] = '*'; Lab[y + 1][x] = ' ';
- Sleep(50);
- system("cls");
- for (int i = 0; i < 12; i++) {
- for (int j = 0; j < 12; j++) {
- printf("%c ", Lab[i][j]);
- };
- printf("\n");
- };
- }
- else if (Lab[y + 1][x] == ' ') {
- d = 'd'; y++; Lab[y][x] = '*'; Lab[y - 1][x] = ' ';
- Sleep(50);
- system("cls");
- for (int i = 0; i < 12; i++) {
- for (int j = 0; j < 12; j++) {
- printf("%c ", Lab[i][j]);
- };
- printf("\n");
- };
- }
- else { d = 'r'; }
- }
- }
- Sleep(50);
- system("cls");
- for (int i = 0; i < 12; i++) {
- for (int j = 0; j < 12; j++) {
- printf("%c ", Lab[i][j]);
- };
- printf("\n");
- };
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement