Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Autor: Dawid Mocek
- */
- #include "stdafx.h"
- #include <stdio.h>
- #include <windows.h> // dla Windows XP
- #define ROWS 10
- #define COLS 10
- void gotoxy(int x, int y)
- {
- COORD c;
- c.X = x - 1;
- c.Y = y - 1;
- SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), c);
- }
- static char tab1[ROWS][COLS] = {
- { ' ', ' ', ' ', '.', '.', '.', '.', ' ', ' ', ' ' },
- { ' ', ' ', '.', ' ', ' ', ' ', ' ', '.', ' ', ' ' },
- { ' ', '.', ' ', ' ', '0', '0', ' ', ' ', '.', ' ' },
- { ' ', '#', ' ', ' ', '#', '#', ' ', ' ', '#', ' ' },
- { ' ', ' ', '#', '#', '#', '#', '#', '#', ' ', ' ' },
- { ' ', ' ', ' ', ' ', '#', '#', ' ', ' ', ' ', ' ' },
- { ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', ' ' },
- { ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', ' ' },
- { ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', ' ' },
- { ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', ' ' }
- };
- static char tab2[ROWS][COLS] = {
- { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
- { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
- { ' ', ' ', ' ', ' ', '0', '0', ' ', ' ', ' ', ' ' },
- { ' ', ' ', ' ', ' ', '#', '#', ' ', ' ', ' ', ' ' },
- { ' ', '#', '#', '#', '#', '#', '#', '#', '#', ' ' },
- { '#', ' ', ' ', ' ', '#', '#', ' ', ' ', ' ', '#' },
- { ' ', '.', '.', '#', '.', '.', '#', '.', '.', ' ' },
- { ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', ' ' },
- { ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', ' ' },
- { ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', ' ' }
- };
- static char tab3[ROWS][COLS] = {
- { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
- { ' ', ' ', ' ', ' ', '0', '0', ' ', ' ', ' ', ' ' },
- { ' ', ' ', ' ', ' ', '#', '#', ' ', ' ', ' ', ' ' },
- { ' ', ' ', ' ', '#', '#', '#', '#', ' ', ' ', ' ' },
- { ' ', ' ', '#', ' ', '#', '#', ' ', '#', ' ', ' ' },
- { ' ', '#', ' ', '#', ' ', ' ', '#', ' ', '#', ' ' },
- { ' ', '#', ' ', '#', ' ', ' ', '#', ' ', '#', ' ' },
- { ' ', '.', ' ', '#', ' ', ' ', '#', ' ', '.', ' ' },
- { ' ', ' ', '.', '#', ' ', ' ', '#', '.', ' ', ' ' },
- { ' ', ' ', ' ', '.', '.', '.', '.', ' ', ' ', ' ' }
- };
- /*
- static long tab4[10][10] = {
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 2, 2, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 },
- { 0, 0, 0, 1, 1, 1, 1, 0, 0, 0 },
- { 0, 0, 1, 0, 1, 1, 0, 1, 0, 0 },
- { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 },
- { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 },
- { 0, 3, 0, 1, 0, 0, 1, 0, 3, 0 },
- { 0, 0, 3, 1, 0, 0, 1, 3, 0, 0 },
- { 0, 0, 0, 3, 3, 3, 3, 0, 0, 0 }
- };
- */
- enum Steps { ONE = 0, TWO = 1, THREE = 2 };
- static void Tlo()
- {
- printf("Tab1: %d Bytes, Tab2: %d Bytes, Tab3 %d Bytes, Steps: %d Bytes, ", sizeof(tab1), sizeof(tab2), sizeof(tab3), sizeof(Steps));
- //printf("Tab4 %d Bytes", sizeof(tab4));
- gotoxy(16, 5);
- printf(" Laboratorium Inzynierii Programowania ");
- gotoxy(16, 7);
- printf("Cwiczenie nr 5 Optymalizacja pamieciowa programow");
- gotoxy(16, 9);
- printf(" TRZEJ MEZCZYZNI SKACZACY PRZEZ SKAKANKE ");
- gotoxy(16, 23);
- printf("-------------------------------------------------");
- }
- static void Loop(char tab[ROWS][COLS],short int x, short int y)
- {
- short int i, j;
- for (i = 0; i <= (COLS - 1); i++) {
- for (j = 0; j <= (ROWS - 1); j++) {
- gotoxy((int)(x + i), (int)(y + j));
- putchar(tab[j][i]);
- }
- }
- }
- static void Faza(enum Steps ktora, short int x, short int y)
- {
- short int i, j;
- if(ktora == ONE)
- {
- Loop(tab1,x,y);
- Sleep (130);
- }
- else if(ktora == TWO)
- {
- Loop(tab2,x,y);
- Sleep (100);
- }
- else if(ktora == THREE)
- {
- Loop(tab3,x,y);
- Sleep (130);
- }
- }
- static void Faza2Replay()
- {
- Faza(TWO, 16,12);
- Faza(TWO, 36,12);
- Faza(TWO, 56,12);
- }
- static void Pokaz()
- {
- Faza2Replay();
- Faza(THREE, 16, 12);
- Faza(THREE, 36, 12);
- Faza(THREE, 56, 12);
- Faza2Replay();
- Faza(ONE, 16, 12);
- Faza(ONE, 36, 12);
- Faza(ONE, 56, 12);
- }
- int main(int argc, char** argv)
- {
- Tlo();
- while (1)
- Pokaz();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement