谭浩强版c语言答案82页,[原创] 位运算和bit位操作程序题目答案 -- 谭浩强C语言习题...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

50.     usDest = usDest | usTemp;

51.     return usDest;

52.}

53.

54.int test_12_1()

55.{

56.     unsigned short usRet = 0;

57.     usRet = getbits(0x83BD, 4, 7);

58.

59.     if (usRet == 0xB)

60.     {

61.         printf("Test_12_1 Passed! \r\n");

62.         return 0;

63.     }

64.

65.     return 1;

66.}

67.

68.int test_12_2()

69.{

70.     int ite = 0, iRet = 0;

71.     unsigned short usDest = 0, usSrc = 0xFFFF, usMask = 0;

72.

73.     for(ite = 0; ite < 16; ite += 2)

74.     {

75.         usMask = 1 << ite;

76.         usDest = usDest | (usSrc & usMask);

77.     }

78.

79.     if (usDest == 0x5555)

80.     {

81.         printf("Test_12_2 Passed! \r\n");

82.         return 0;

83.     }

84.

85.     return 1;

86.}

87.

88.int test_12_4()

89.{

90.     unsigned short usDest1 = 0, usDest2 = 0, usSrc = 0xFFF7;

91.

92.     usDest1 = move(0xFFF7, 4);

93.     usDest2 = move(0xFFF7, -4);

94.

95.     if (usDest1 == 0x7FFF && usDest2 == 0xFF7F)

96.     {

97.         printf("Test_12_4 Passed! \r\n");

98.         return 0;

99.     }

100.     return 1;

101.}

102.

103.int test_12_5()

104.{

105.     short sDest = 0, sSrc = -10;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值