#include <stdio.h> #include <stdint.h> union Register { uint32_t value; uint8_t reg[4]; }; uint32_t convert_endian(uint32_t value) { Register var; var.value = value; for(int i=0,j=3;i<j;i++,j--){ int temp = var.reg[i]; var.reg[i] = var.reg[j]; var.reg[j] = temp; } return var.value; } int main() { uint32_t val; scanf("%u", &val); printf("%u", convert_endian(val)); return 0; }
Test Cases
Test Results
Input
305419896
Expected Output
2018915346