#include <stdio.h> #include<math.h> unsigned int modifyBit(unsigned int reg, int pos, int mode) { int A[8]; for (int i=0; i<8; i++) { A[i]= (reg % 2); reg /= 2; } A[pos]= mode; int z=0; for (0; i<8; i++) { z+= (A[i]*pow(2,i)); }int i= return z; } int main() { unsigned int reg; int pos, mode; scanf("%d %d %d", ®, &pos, &mode); printf("%d", modifyBit(reg, pos, mode)); return 0; }
Test Cases
Test Results
Input
10 3 1
Expected Output
10