Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.07 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <conio2.h>
  4.  
  5. #define TAMX 8
  6. #define TAMY 25
  7.  
  8.  
  9. int brandom (void) {
  10.     int r;
  11.     r = rand () % 2;
  12.     if (r == 1) return 0;
  13.     else return 1;
  14. }
  15.  
  16. int main() {
  17.     int board[TAMX][TAMY], i, j, num;
  18.     for (i=0; i<TAMX; i++) {
  19.         for (j=0; j<TAMY; j++)
  20.             if (i==0 && j ==0) board[0][0]=0;
  21.             else board[i][j]=brandom();
  22.             }
  23.     system("cls");
  24.     int c, x=0, y=0;
  25.     do {
  26.         system("cls");
  27.         if (c=='LEFT_KEY') { x--; }
  28.         if (c=='RIGHT_KEY') { x++; }
  29.         if (c=='UP_KEY') { y--; }
  30.         if (c=='DOWN_KEY') { y++; }
  31.             gotoxy(x,y);
  32.             for (i=0;i<TAMX;i++) {
  33.             for (j=0;j<TAMY;j++) {
  34.                      if (board[i][j]==0) { printf("%c", 35); }
  35.                      else { printf("|"); }
  36.                      }
  37.                      printf(" \n");
  38.                 }
  39.                 gotoxy(0,0);
  40.                 c = getch();
  41.                 }
  42.     while(c!='ESC');
  43.     printf("\n");
  44.     system("pause");
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement