daily pastebin goal
15%
SHARE
TWEET

auto v2

a guest Feb 13th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //2 pohyb auta: nakreslite auto zo znakov a posunte ho 10x o 1 stlpec doprava.
  2. //auto pri posuvaní pípa, posledne auto zostane na obrazovke
  3.  
  4. #include <stdio.h>
  5. #include <time.h>
  6. #include <stdlib.h>
  7.  
  8. #ifdef _WIN32 //Windows
  9.     #include <Windows.h>
  10.    
  11.     void gotoxy (short x, short y){
  12.         COORD pos = {x,y};
  13.         SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
  14.     }
  15. #else //linux alebo iny system
  16.     #include <unistd.h>
  17.    
  18.     #define gotoxy(x,y) printf("%c[%d;%df",0x1B,y,x); //printf("\033[%d;%dH", (x), (y))
  19.     #define Beep(a,b)
  20.     #define Sleep(ms) usleep(ms*1000);
  21. #endif
  22.  
  23. int main(){
  24.     int i;
  25.    
  26.     for (i=1;i<=10;i++){  
  27.        
  28.         gotoxy(i,1); printf("           -------\n");
  29.         gotoxy(i,2); printf("          /       I\n");
  30.         gotoxy(i,3); printf("       ---         ----\n");
  31.         gotoxy(i,4); printf("      /                J\n");
  32.         gotoxy(i,5); printf("      -----()-------()---I\n");
  33.        
  34.         Beep(500,100);
  35.         Sleep(300);
  36.        
  37.         if(i!=10){
  38.         #ifdef _WIN32 //Windows
  39.             system("cls");
  40.         #else //linux alebo iny system
  41.             printf("\033[2J");
  42.         #endif
  43.         }
  44.     }
  45.    
  46.     gotoxy(0,20);      
  47.    
  48.     return 0;
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top