Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3. typedef unsigned char uint8;
  4. int main()
  5. {
  6.    uint8 startBit,byte2,byte5,flag;
  7.    
  8.    time_t t;
  9.    
  10.    srand((unsigned) time(&t));
  11.    byte2 = (rand()%255);
  12.    byte2 = 9;
  13.    byte5 = (rand()%255);
  14.    byte5 = 58;
  15.    startBit = 4;
  16.    
  17.    //9 is 1001 binary, used as a mask here
  18.    if(byte2&9 == 9){
  19.     //8 is 1000 binary,used as a mask here
  20.        if((byte5&8) == 8){
  21.            flag = 1;
  22.            
  23.            switch(byte5>>startBit){
  24.                
  25.                case 0:
  26.                printf("HighlightBlue - Basic");
  27.                break;
  28.                
  29.                case 1:
  30.                printf("No Color - Advanced");
  31.                break;
  32.                
  33.                case 2:
  34.                printf("No Color - Sport");
  35.                break;
  36.                
  37.                case 3:
  38.                printf("HighlightYellow - Drift");
  39.                break;
  40.            }
  41.            
  42.        }else{
  43.            flag = 0;
  44.            
  45.            switch(byte5>>startBit){
  46.                
  47.                case 0:
  48.                printf("No Color - Basic");
  49.                break;
  50.                
  51.                case 1:
  52.                printf("No Color - Advanced");
  53.                break;
  54.                
  55.                case 2:
  56.                printf("No Color - Sport");
  57.                break;
  58.                
  59.                case 3:
  60.                printf("No Color - Drift");
  61.                break;
  62.            }
  63.        }
  64.    }
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement