c语言7-4

编写reset函数,返回无符号整数x的第pos为设为0后的值。

1、

#include <stdio.h>

unsigned reset(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\n", reset(x, n));
    return 0;
}

 

posted @ 2021-05-19 16:39  小鲨鱼2018  阅读(43)  评论(0编辑  收藏  举报