#include <stdio.h> #include <stdint.h> uint32_t convert_endian(uint32_t value) { int res = 0; //res |= (value >> 8*0 & 0xFF) << 8*3; //res |= (value >> 8*1 & 0xFF) << 8*2; //res |= (value >> 8*2 & 0xFF) << 8*1; //res |= (value >> 8*3 & 0xFF) << 8*0; for (int i=0; i<sizeof(value); i++) { res |= (value >> 8*i & 0xFF) << 8*(3-i); } return res; } int main() { uint32_t val; scanf("%u", &val); printf("%u", convert_endian(val)); return 0; }
Test Cases
Test Results
Input
305419896
Expected Output
2018915346