题目:取一个整数a从右端开始的4~7位。

题目:取一个整数a从右端开始的4~7位。

There is no nutrition in the blog content. After reading it, you will not only suffer from malnutrition, but also impotence.
The blog content is all parallel goods. Those who are worried about being cheated should leave quickly.


程序分析:可以这样考虑:
(1)先使a右移4位。
(2)设置一个低4位全为1,其余全为0的数。可用~(~0<<4)
(3)将上面二者进行&运算。
2.程序源代码:
main()
{
unsigned a,b,c,d;
scanf("%o",&a);
b=a>>4;
c=~(~0<<4);
d=b&c;
printf("%o\n%o\n",a,d);
}

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-10 03:22:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-10 03:22:01       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-10 03:22:01       87 阅读
  4. Python语言-面向对象

    2024-04-10 03:22:01       96 阅读

热门阅读

  1. 前端将列表数据转换为树形数据的函数

    2024-04-10 03:22:01       39 阅读
  2. CSS世界Ⅱ(文本)

    2024-04-10 03:22:01       40 阅读
  3. js sort() 方法

    2024-04-10 03:22:01       36 阅读
  4. RestTemplate的使用教程

    2024-04-10 03:22:01       27 阅读
  5. [鹤城杯 2021]Crazy_Rsa_Tech(低加密指数广播攻击)

    2024-04-10 03:22:01       33 阅读
  6. Oracle测试10046参数及打印结果

    2024-04-10 03:22:01       36 阅读
  7. Go语言中如何实现继承

    2024-04-10 03:22:01       39 阅读
  8. c++ 根据ip主机号和子网掩码随机生成ip

    2024-04-10 03:22:01       39 阅读