Advertisement
Guest User

lab

a guest
Nov 21st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.82 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4.  
  5. int main() {
  6.     char Lab[12][12] = {
  7.  
  8.         { '#','#','#','#','#','#','#','#','#','#','#','#' },
  9.         { '#','#','#','#','#','#','#','#','#',' ','*','#' },
  10.         { '#','#','#','#','#','#','#','#','#',' ','#','#' },
  11.         { '#','#','#','#','#','#',' ','#','#',' ',' ','#' },
  12.         { '#','#','#','#','#','#',' ',' ',' ',' ','#','#' },
  13.         { '#',' ',' ','#',' ',' ',' ',' ','#','#','#','#' },
  14.         { '#','#',' ','#',' ','#','#','#','#','#','#','#' },
  15.         { '#','#',' ',' ',' ','#','#','#','#','#','#','#' },
  16.         { '#','#',' ','#','#','#','#',' ',' ',' ','#','#' },
  17.         { '#','#',' ',' ',' ','#','#',' ','#',' ','#','#' },
  18.         { '#','#','#','#',' ',' ',' ',' ','#','@','#','#' },
  19.         { '#','#','#','#','#','#','#','#','#','#','#','#' }
  20.     };
  21.  
  22.     int x = 0;
  23.     int y = 0;
  24.     char d = 'u';
  25.  
  26.     for (int i = 0; i < 12; i++) {
  27.         for (int j = 0; j < 12; j++) {
  28.             if (Lab[i][j] == '*') {
  29.                 y = i;
  30.                 x = j;
  31.             };
  32.         };
  33.     };
  34.  
  35.     while (Lab[y][x] != '@') {
  36.         if (Lab[y + 1][x] == '@' || Lab[y - 1][x] == '@' || Lab[y][x + 1] == '@' || Lab[y][x - 1] == '@') { Lab[y][x] = '@'; }
  37.         if (d == 'u') {
  38.             while (Lab[y - 1][x] == ' ' && Lab[y][x + 1] == '#') {
  39.                 y--;
  40.                 Lab[y][x] = '*';
  41.                 Lab[y + 1][x] = ' ';
  42.                 Sleep(50);
  43.                 system("cls");
  44.                 for (int i = 0; i < 12; i++) {
  45.                     for (int j = 0; j < 12; j++) {
  46.                         printf("%c ",Lab[i][j]);
  47.                     };
  48.                     printf("\n");
  49.                 };
  50.             }
  51.             if (Lab[y][x + 1] == ' ') {
  52.                 d = 'r'; x++; Lab[y][x] = '*'; Lab[y][x - 1] = ' ';
  53.                 Sleep(100);
  54.                 system("cls");
  55.                 for (int i = 0; i < 12; i++) {
  56.                     for (int j = 0; j < 12; j++) {
  57.                         printf("%c ", Lab[i][j]);
  58.                     };
  59.                     printf("\n");
  60.                 }
  61.             }
  62.  
  63.             else if (Lab[y][x - 1] == ' ') {
  64.                 d = 'l'; x--; Lab[y][x] = '*'; Lab[y][x + 1] = ' ';
  65.                 Sleep(50);
  66.                 system("cls");
  67.                 for (int i = 0; i < 12; i++) {
  68.                     for (int j = 0; j < 12; j++) {
  69.                         printf("%c ", Lab[i][j]);
  70.                     };
  71.                     printf("\n");
  72.                 };
  73.             }
  74.             else { d = 'd'; }
  75.         }
  76.         else if (d == 'r') {
  77.             while (Lab[y][x + 1] == ' ' && Lab[y + 1][x] == '#') {
  78.                 x++;
  79.                 Lab[y][x] = '*';
  80.                 Lab[y][x - 1] = ' ';
  81.                 Sleep(50);
  82.                 system("cls");
  83.                 for (int i = 0; i < 12; i++) {
  84.                     for (int j = 0; j < 12; j++) {
  85.                         printf("%c ", Lab[i][j]);
  86.                     };
  87.                     printf("\n");
  88.                 };
  89.             }
  90.             if (Lab[y + 1][x] == ' ') {
  91.                 d = 'd'; y++; Lab[y][x] = '*'; Lab[y - 1][x] = ' ';
  92.                 Sleep(50);
  93.                 system("cls");
  94.                 for (int i = 0; i < 12; i++) {
  95.                     for (int j = 0; j < 12; j++) {
  96.                         printf("%c ", Lab[i][j]);
  97.                     };
  98.                     printf("\n");
  99.                 };
  100.             }
  101.             else if (Lab[y - 1][x] == ' ') {
  102.                 d = 'u'; y--; Lab[y][x] = '*'; Lab[y + 1][x] = ' ';
  103.                 Sleep(50);
  104.                 system("cls");
  105.                 for (int i = 0; i < 12; i++) {
  106.                     for (int j = 0; j < 12; j++) {
  107.                         printf("%c ", Lab[i][j]);
  108.                     };
  109.                     printf("\n");
  110.                 };
  111.             }
  112.             else { d = 'l'; }
  113.         }
  114.         else if (d == 'd') {
  115.             while (Lab[y + 1][x] == ' ' && Lab[y][x - 1] == '#') {
  116.                 y++;
  117.                 Lab[y][x] = '*';
  118.                 Lab[y - 1][x] = ' ';
  119.                 Sleep(50);
  120.                 system("cls");
  121.                 for (int i = 0; i < 12; i++) {
  122.                     for (int j = 0; j < 12; j++) {
  123.                         printf("%c ", Lab[i][j]);
  124.                     };
  125.                     printf("\n");
  126.                 };
  127.             }
  128.             if (Lab[y][x - 1] == ' ') {
  129.                 d = 'l'; x--; Lab[y][x] = '*'; Lab[y][x + 1] = ' ';
  130.                 Sleep(50);
  131.                 system("cls");
  132.                 for (int i = 0; i < 12; i++)
  133.                 {
  134.                     for (int j = 0; j < 12; j++) {
  135.                         printf("%c ", Lab[i][j]);
  136.                     };
  137.                     printf("\n");
  138.                 };
  139.             }
  140.             else if (Lab[y][x + 1] == ' ') {
  141.                 d = 'r'; x++; Lab[y][x] = '*'; Lab[y][x - 1] = ' ';
  142.                 Sleep(50);
  143.                 system("cls");
  144.                 for (int i = 0; i < 12; i++) {
  145.                     for (int j = 0; j < 12; j++) {
  146.                         printf("%c ", Lab[i][j]);
  147.                     };
  148.                     printf("\n");
  149.                 };
  150.             }
  151.             else { d = 'u'; }
  152.         }
  153.         else if (d == 'l') {
  154.             while (Lab[y][x - 1] == ' ' && Lab[y - 1][x] == '#') {
  155.                 x--;
  156.                 Lab[y][x] = '*';
  157.                 Lab[y][x + 1] = ' ';
  158.                 Sleep(50);
  159.                 system("cls");
  160.                 for (int i = 0; i < 12; i++) {
  161.                     for (int j = 0; j < 12; j++) {
  162.                         printf("%c ", Lab[i][j]);
  163.                     };
  164.                     printf("\n");
  165.                 };
  166.             }
  167.             if (Lab[y - 1][x] == ' ') {
  168.                 d = 'u'; y--; Lab[y][x] = '*'; Lab[y + 1][x] = ' ';
  169.                 Sleep(50);
  170.                 system("cls");
  171.                 for (int i = 0; i < 12; i++) {
  172.                     for (int j = 0; j < 12; j++) {
  173.                         printf("%c ", Lab[i][j]);
  174.                     };
  175.                     printf("\n");
  176.                 };
  177.             }
  178.             else if (Lab[y + 1][x] == ' ') {
  179.                 d = 'd'; y++; Lab[y][x] = '*'; Lab[y - 1][x] = ' ';
  180.                 Sleep(50);
  181.                 system("cls");
  182.                 for (int i = 0; i < 12; i++) {
  183.                     for (int j = 0; j < 12; j++) {
  184.                         printf("%c ", Lab[i][j]);
  185.                     };
  186.                     printf("\n");
  187.                 };
  188.             }
  189.             else { d = 'r'; }
  190.         }
  191.     }
  192.     Sleep(50);
  193.     system("cls");
  194.     for (int i = 0; i < 12; i++) {
  195.         for (int j = 0; j < 12; j++) {
  196.             printf("%c ", Lab[i][j]);
  197.         };
  198.         printf("\n");
  199.     };
  200.     system("pause");
  201.     return 0;
  202. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement