Advertisement
Guest User

Untitled

a guest
May 27th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3.  
  4. // 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
  5. // O A A R R R 0 1 D D D D D D D
  6.  
  7. int main()
  8. {
  9. while (0==0) {
  10.  
  11. unsigned int res = 0;
  12. char O;
  13. char A;
  14. char R;
  15. char key1 = 0;
  16. char key2 = 1;
  17. unsigned char D;
  18.  
  19. printf("O - тип операции (0 - 1): ");
  20. scanf("%hhd", &O);
  21.  
  22. printf("A - код области диска (0 - 3): ");
  23. scanf("%hhd", &A);
  24.  
  25. printf("R - возможные реакции на ошибку (0 - 7): ");
  26. scanf("%hhd", &R);
  27.  
  28. printf("D - номер диска (0 - 255): ");
  29. scanf("%hhd", &D);
  30.  
  31. res |= ((unsigned char)O & 1) << 15;
  32. res |= ((unsigned char)A & 3) << 13;
  33. res |= ((unsigned char)R & 7) << 10;
  34. res |= ((unsigned char)key1 & 1) << 9;
  35. res |= ((unsigned char)key2 & 1) << 8;
  36. res |= D & 0xFF;
  37.  
  38. printf("\nResult: %04x \n\n", res);
  39. }
  40. system("pause");
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement