Advertisement
m4ly

Skakanka

Nov 16th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.88 KB | None | 0 0
  1. /*
  2. Autor: Dawid Mocek
  3.  
  4. */
  5. #include "stdafx.h"
  6. #include <stdio.h>
  7. #include <windows.h> // dla Windows XP
  8.  
  9. #define ROWS 10
  10. #define COLS 10
  11.  
  12. void gotoxy(int x, int y)
  13. {
  14.     COORD c;
  15.     c.X = x - 1;
  16.     c.Y = y - 1;
  17.     SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), c);
  18. }
  19.  
  20. static char tab1[ROWS][COLS] = {
  21.     { ' ', ' ', ' ', '.', '.', '.', '.', ' ', ' ', ' ' },
  22.     { ' ', ' ', '.', ' ', ' ', ' ', ' ', '.', ' ', ' ' },
  23.     { ' ', '.', ' ', ' ', '0', '0', ' ', ' ', '.', ' ' },
  24.     { ' ', '#', ' ', ' ', '#', '#', ' ', ' ', '#', ' ' },
  25.     { ' ', ' ', '#', '#', '#', '#', '#', '#', ' ', ' ' },
  26.     { ' ', ' ', ' ', ' ', '#', '#', ' ', ' ', ' ', ' ' },
  27.     { ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', ' ' },
  28.     { ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', ' ' },
  29.     { ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', ' ' },
  30.     { ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', ' ' }
  31. };
  32.  
  33. static char tab2[ROWS][COLS] = {
  34.     { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
  35.     { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
  36.     { ' ', ' ', ' ', ' ', '0', '0', ' ', ' ', ' ', ' ' },
  37.     { ' ', ' ', ' ', ' ', '#', '#', ' ', ' ', ' ', ' ' },
  38.     { ' ', '#', '#', '#', '#', '#', '#', '#', '#', ' ' },
  39.     { '#', ' ', ' ', ' ', '#', '#', ' ', ' ', ' ', '#' },
  40.     { ' ', '.', '.', '#', '.', '.', '#', '.', '.', ' ' },
  41.     { ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', ' ' },
  42.     { ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', ' ' },
  43.     { ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', ' ' }
  44. };
  45.  
  46. static char tab3[ROWS][COLS] = {
  47.     { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
  48.     { ' ', ' ', ' ', ' ', '0', '0', ' ', ' ', ' ', ' ' },
  49.     { ' ', ' ', ' ', ' ', '#', '#', ' ', ' ', ' ', ' ' },
  50.     { ' ', ' ', ' ', '#', '#', '#', '#', ' ', ' ', ' ' },
  51.     { ' ', ' ', '#', ' ', '#', '#', ' ', '#', ' ', ' ' },
  52.     { ' ', '#', ' ', '#', ' ', ' ', '#', ' ', '#', ' ' },
  53.     { ' ', '#', ' ', '#', ' ', ' ', '#', ' ', '#', ' ' },
  54.     { ' ', '.', ' ', '#', ' ', ' ', '#', ' ', '.', ' ' },
  55.     { ' ', ' ', '.', '#', ' ', ' ', '#', '.', ' ', ' ' },
  56.     { ' ', ' ', ' ', '.', '.', '.', '.', ' ', ' ', ' ' }
  57. };
  58. /*
  59. static long tab4[10][10] = {
  60.   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  61.   { 0, 0, 0, 0, 2, 2, 0, 0, 0, 0 },
  62.   { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 },
  63.   { 0, 0, 0, 1, 1, 1, 1, 0, 0, 0 },
  64.   { 0, 0, 1, 0, 1, 1, 0, 1, 0, 0 },
  65.   { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 },
  66.   { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 },
  67.   { 0, 3, 0, 1, 0, 0, 1, 0, 3, 0 },
  68.   { 0, 0, 3, 1, 0, 0, 1, 3, 0, 0 },
  69.   { 0, 0, 0, 3, 3, 3, 3, 0, 0, 0 }
  70. };
  71. */
  72. enum Steps { ONE = 0, TWO = 1, THREE = 2 };
  73.  
  74. static void Tlo()
  75. {
  76.     printf("Tab1: %d Bytes, Tab2: %d Bytes, Tab3 %d Bytes, Steps: %d Bytes, ", sizeof(tab1), sizeof(tab2), sizeof(tab3), sizeof(Steps));
  77.     //printf("Tab4 %d Bytes", sizeof(tab4));
  78.     gotoxy(16, 5);
  79.     printf("      Laboratorium Inzynierii Programowania      ");
  80.     gotoxy(16, 7);
  81.     printf("Cwiczenie nr 5 Optymalizacja pamieciowa programow");
  82.     gotoxy(16, 9);
  83.     printf("     TRZEJ MEZCZYZNI SKACZACY PRZEZ SKAKANKE     ");
  84.     gotoxy(16, 23);
  85.     printf("-------------------------------------------------");
  86.  
  87. }
  88.  
  89. static void Loop(char tab[ROWS][COLS],short int x, short int y)
  90. {
  91.     short int i, j;
  92.     for (i = 0; i <= (COLS - 1); i++) {
  93.         for (j = 0; j <= (ROWS - 1); j++) {
  94.             gotoxy((int)(x + i), (int)(y + j));
  95.             putchar(tab[j][i]);
  96.         }
  97.     }
  98. }
  99.  
  100. static void Faza(enum Steps ktora, short int x, short int y)
  101. {
  102.     short int i, j;
  103.  
  104.     if(ktora == ONE)
  105.     {
  106.         Loop(tab1,x,y);
  107.         Sleep (130);
  108.     }
  109.     else if(ktora == TWO)
  110.     {
  111.         Loop(tab2,x,y);
  112.         Sleep (100);
  113.     }
  114.     else if(ktora == THREE)
  115.     {
  116.         Loop(tab3,x,y);
  117.         Sleep (130);
  118.     }
  119. }
  120.  
  121. static void Faza2Replay()
  122. {
  123.     Faza(TWO, 16,12);
  124.     Faza(TWO, 36,12);
  125.     Faza(TWO, 56,12);
  126. }
  127.  
  128. static void Pokaz()
  129. {
  130.  
  131.     Faza2Replay();
  132.     Faza(THREE, 16, 12);
  133.     Faza(THREE, 36, 12);
  134.     Faza(THREE, 56, 12);
  135.     Faza2Replay();
  136.     Faza(ONE, 16, 12);
  137.     Faza(ONE, 36, 12);
  138.     Faza(ONE, 56, 12);
  139. }
  140.  
  141. int main(int argc, char** argv)
  142. {
  143.     Tlo();
  144.  
  145.     while (1)
  146.         Pokaz();
  147.     return 0;
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement