Created
August 26, 2020 03:56
-
-
Save ishikawash/1932e33d20221cb03b37af1267b67955 to your computer and use it in GitHub Desktop.
The NUXI Problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main() | |
{ | |
char text[] = { 'U', 'N', 'I', 'X' }; | |
uint16_t* p = reinterpret_cast<uint16_t*>(text); | |
for (int i = 0; i < sizeof(text)/sizeof(uint16_t); i++) | |
{ | |
uint16_t a = *p; | |
for (int i = sizeof(uint16_t) - 1; i >= 0; i--) | |
{ | |
// Print character from high byte to low byte. | |
char ch = ((a >> i * 8) & 0xFF); | |
std::cout << ch; | |
} | |
p++; | |
} | |
std::cout << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment