Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstddef>
- #include <string>
- #include <cstdint>
- #include <iostream>
- #include <bitset>
- int main() {
- std::string data;
- int counter = 0;
- getline(std::cin, data);
- for (int i = 0; i < data.size(); i++) {
- char tmp = data[i] >> 6;
- if ((tmp & 0b11) == 0b11) {
- char tmp = data[i] >> 5;
- if ((tmp & 0b111) == 0b111) {
- char tmp = data[i] >> 4;
- if ((tmp & 0b1111) == 0b1111) {
- std::bitset<32> A = data[i];
- unsigned long ans = 0b0;
- for (int j = 0; j < 32; j++) {
- if (j < 5)
- continue;
- if (j % 8 < 2)
- continue;
- ans <<= 1;
- if (A[j] == true) {
- if (ans == 0b0) {
- ans += 1;
- }
- }
- }
- std::cout << ans << " ";
- i +=3;
- continue;
- }
- else {
- std::bitset<24> A = data[i];
- unsigned long ans = 0b0;
- for (int j = 0; j < 24; j++) {
- if (j < 4)
- continue;
- if (j % 8 < 2)
- continue;
- ans <<= 1;
- if (A[j] == true) {
- if (ans == 0b0) {
- ans += 1;
- }
- }
- }
- std::cout << ans << " ";
- i +=2;
- continue;
- }
- } else {
- std::bitset<8> A(data[i] >> 8), B();
- std::cout << data[i];
- unsigned long ans = 0b0;
- std::cout << ans << " ";
- i +=1;
- continue;
- }
- }
- std::bitset<8> A = data[i];
- std::cout << A.to_ulong() << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment