ivolff

Untitled

Mar 15th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. #include <cstddef>
  2. #include <string>
  3. #include <cstdint>
  4. #include <iostream>
  5. #include <bitset>
  6.  
  7. int main() {
  8. std::string data;
  9. int counter = 0;
  10. getline(std::cin, data);
  11. for (int i = 0; i < data.size(); i++) {
  12. char tmp = data[i] >> 6;
  13. if ((tmp & 0b11) == 0b11) {
  14. char tmp = data[i] >> 5;
  15. if ((tmp & 0b111) == 0b111) {
  16. char tmp = data[i] >> 4;
  17. if ((tmp & 0b1111) == 0b1111) {
  18. std::bitset<32> A = data[i];
  19. unsigned long ans = 0b0;
  20. for (int j = 0; j < 32; j++) {
  21. if (j < 5)
  22. continue;
  23. if (j % 8 < 2)
  24. continue;
  25. ans <<= 1;
  26. if (A[j] == true) {
  27. if (ans == 0b0) {
  28. ans += 1;
  29. }
  30. }
  31. }
  32. std::cout << ans << " ";
  33. i +=3;
  34. continue;
  35. }
  36. else {
  37. std::bitset<24> A = data[i];
  38. unsigned long ans = 0b0;
  39. for (int j = 0; j < 24; j++) {
  40. if (j < 4)
  41. continue;
  42. if (j % 8 < 2)
  43. continue;
  44. ans <<= 1;
  45. if (A[j] == true) {
  46. if (ans == 0b0) {
  47. ans += 1;
  48. }
  49. }
  50. }
  51. std::cout << ans << " ";
  52. i +=2;
  53. continue;
  54. }
  55. } else {
  56. std::bitset<8> A(data[i] >> 8), B();
  57. std::cout << data[i];
  58. unsigned long ans = 0b0;
  59.  
  60. std::cout << ans << " ";
  61. i +=1;
  62. continue;
  63. }
  64. }
  65. std::bitset<8> A = data[i];
  66. std::cout << A.to_ulong() << " ";
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment