j4ggi

Untitled

Jun 13th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <ctime>
  4. #include <cmath>
  5. #include <windows.h>
  6. #include <string>
  7.  
  8. #define USTAW SetConsoleTextAttribute(handle,
  9. #define _X_ BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY );
  10. #define CZE FOREGROUND_RED |
  11. #define NIE FOREGROUND_BLUE |
  12. #define ZIE FOREGROUND_GREEN |
  13. #define INTENS FOREGROUND_INTENSITY |
  14.  
  15. using namespace std;
  16.  
  17. void color(short color=0);
  18. void convert();
  19. void print(string&, short a=0);
  20.  
  21. void color(short color)
  22. {
  23.     HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);
  24.     USTAW _X_
  25.     switch(color)
  26.     {
  27.         case 0: USTAW CZE NIE ZIE INTENS _X_ break;
  28.         case 1: USTAW CZE INTENS _X_ break;
  29.         case 2: USTAW ZIE INTENS _X_ break;
  30.         case 3: USTAW NIE INTENS _X_ break;
  31.         case 4: USTAW NIE ZIE INTENS _X_ break;
  32.         case 5: USTAW CZE NIE _X_ break;
  33.         default: USTAW CZE NIE ZIE _X_ break;
  34.     }
  35. }
  36. void print(string& napis, short a)
  37. {
  38.     long long x1=time(NULL), x2;
  39.     srand (time(NULL));
  40.     if(!a)
  41.         do
  42.         {
  43.             x2=time(NULL);
  44.             color( rand()%4 +1 );
  45.             cout<<napis<<"\r";
  46.         }while(x2-x1<5);
  47.     else
  48.         for(int i=0;i<20;i++)
  49.         {
  50.         color( rand()%6 +1 );
  51.         cout<<napis<<endl;
  52.         }
  53. }
  54.  
  55. void convert()
  56. {
  57.     string* zyczenia=new string[24];
  58.     for(int i=0; i<24; i++)
  59.             cin>>zyczenia[i];
  60.     int tab[24][8];
  61.     for(int i=0;i<24; i++)
  62.     for(int j=0;j<8;j++)
  63.     {
  64.         if(zyczenia[i][j]=='0') tab[i][j]=0;
  65.         if(zyczenia[i][j]=='1') tab[i][j]=1;
  66.     }
  67.     string z="Zaczekaj...";
  68.     print(z);
  69.     string a;
  70.     int suma=0, x=0;
  71.     for(int i=0;i<24;i++)
  72.     {
  73.         for(int j=0; j<8; j++)
  74.         suma+=tab[i][j]*pow(2,7-j);
  75.         a+=(char) (suma);
  76.         suma=0;
  77.     }
  78.     a="==> "+ a;
  79.     print(a, 1);
  80. }
  81. int main()
  82. {
  83.     convert();
  84.     getch();
  85.     return 0;
  86. }
  87.  
  88. /*
  89. 01010111 01110011 01111010 01111001 01110011 01110100 01101011 01101001 01100101 01100111 01101111 00100000 01001110 01100001 01101010 01101100 01100101 01110000 01110011 01111010 01100101 01100111 01101111 00100001
  90. */
Advertisement
Add Comment
Please, Sign In to add comment