#include <stdio.h> #include <stdint.h> uint32_t set_baud_rate(uint32_t reg, uint8_t baud) { for (uint8_t i = 0; i < 4; i++) { if ((baud >> i) & 1) { // Set reg |= (1U << (i + 8)); } else { // Reset reg &= ~(1U << (i + 8)); } } return reg; } int main() { uint32_t reg; uint8_t baud; scanf("%u %hhu", ®, &baud); printf("%u", set_baud_rate(reg, baud)); return 0; }
Test Cases
Test Results
Input
0 10
Expected Output
2560