编写函数,返回将无符号整数的第pos位设置为1后的值。
1、
#include <stdio.h>
unsigned set(unsigned x, int pos)
{
return (x | 1 << pos);
}
int main(void)
{
unsigned x;
int n;
puts("please input two nonnegative integers.");
printf("x = "); scanf("%u", &x);
printf("n = "); scanf("%d", &n);
printf("result: %u
", set(x, n));
return 0;
}