C 练习实例 54
C 语言教程
· 2019-02-22 07:26:38
题目:取一个整数 a 从右端开始的 4~7 位。
程序分析:可以这样考虑:
(1)先使 a 右移 4 位。
(2)设置一个低 4 位全为 1,其余全为 0 的数,可用~(~0<<4)
(3)将上面二者进行 & 运算。
实例
// Created by www.codercto.com on 15/11/9.
// Copyright © 2015年 码农教程. All rights reserved.
//
#include <stdio.h>
int main()
{
unsigned a,b,c,d;
printf("请输入整数:\n");
scanf("%o",&a);
b=a>>4;
c=~(~0<<4);
d=b&c;
printf("%o\n%o\n",a,d);
return 0;
}
以上实例输出结果为:
请输入整数: 36 36 1
点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html
Mastering JavaServer Faces
Bill Dudney、Jonathan Lehr、Bill Willis、LeRoy Mattingly / Wiley / 2004-6-7 / USD 40.00
Harness the power of JavaServer Faces to create your own server-side user interfaces for the Web This innovative book arms you with the tools to utilize JavaServer Faces (JSF), a new standard that wi......一起来看看 《Mastering JavaServer Faces》 这本书的介绍吧!