All submissions

Little Endian to Big Endian

Code

#include <stdio.h>
#include <stdint.h>

uint32_t convert_endian(uint32_t v) {
    return (v << 24 & 0xff000000) | 
           (v << 8 & 0x00ff0000) |
           (v >> 8 & 0x0000ff00) |
           (v >> 24 & 0x000000ff);
}

int main() {
    uint32_t val;
    scanf("%u", &val);
    printf("%u", convert_endian(val));
    return 0;
}

Solving Approach


 

Loading...

Input

305419896

Expected Output

2018915346