上一页 1 ··· 278 279 280 281 282 283 284 285 286 ··· 367 下一页
摘要: c语言中使用十进制、二进制、八进制和十六进制输出0到65535的整数。 1、 #include <stdio.h> int count_bits(unsigned x) { int bits = 0; while(x) { if(x & 1U) bits++; x >>= 1; } return b 阅读全文
posted @ 2021-05-21 16:17 小鲨鱼2018 阅读(439) 评论(0) 推荐(0) 编辑
摘要: c语言中printf函数输出十进制、八进制和十六进制数。 1、 #include <stdio.h> int main(void) { unsigned a = 45; printf("101010 %u\n", a); printf("888888 %o\n", a); printf("16161 阅读全文
posted @ 2021-05-21 15:59 小鲨鱼2018 阅读(2865) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> unsigned set_n(unsigned x, int pos, int n) { int i; for(i = pos; i <= pos + n - 1; i++) { x = x | 1U << i; } return x; } unsigne 阅读全文
posted @ 2021-05-21 12:50 小鲨鱼2018 阅读(72) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> unsigned set(unsigned x, int pos) { return x | 1U << pos; } unsigned reset(unsigned x, int pos) { return x & (~(1U << pos)); } u 阅读全文
posted @ 2021-05-21 11:44 小鲨鱼2018 阅读(74) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> unsigned rrotate(unsigned x, int n) { return x >> n; } unsigned lrotate(unsigned x, int n) { return x << n; } int main(void) { u 阅读全文
posted @ 2021-05-21 11:12 小鲨鱼2018 阅读(62) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> #include <math.h> int main(void) { unsigned x, n; printf("test number: "); scanf("%u", &x); printf("move bits : "); scanf("%u", 阅读全文
posted @ 2021-05-21 10:29 小鲨鱼2018 阅读(74) 评论(0) 推荐(0) 编辑
摘要: c语言中输出十进制转换为二进制结果并指定显示的位数。 1、 #include <stdio.h> int count_bits(unsigned x) { int bits = 0; while(x) { if(x & 1U) bits++; x >>= 1; } return bits; } in 阅读全文
posted @ 2021-05-21 09:33 小鲨鱼2018 阅读(600) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> int count_bits(unsigned x) { int bits = 0; while(x) { if(x & 1U) bits++; x >>= 1; } return bits; } int int_bits(void) { return c 阅读全文
posted @ 2021-05-21 09:15 小鲨鱼2018 阅读(217) 评论(0) 推荐(0) 编辑
摘要: c语言中将一个十进制数按照二进制输出 1、 #include <stdio.h> int main(void) { int bits = 0; unsigned tmp = ~0U; while(tmp) { if(tmp & 1U) bits++; tmp >>= 1; } int i; unsi 阅读全文
posted @ 2021-05-21 08:22 小鲨鱼2018 阅读(597) 评论(0) 推荐(0) 编辑
摘要: c语言中输出不同数据类型在内存中的占位 1、 #include <stdio.h> int main(void) { int n = 0; unsigned x = ~0U; while(x) { if(x & 1U) n++; x >>= 1; } printf("the number of bi 阅读全文
posted @ 2021-05-20 23:05 小鲨鱼2018 阅读(274) 评论(0) 推荐(0) 编辑
上一页 1 ··· 278 279 280 281 282 283 284 285 286 ··· 367 下一页