会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
小鲨鱼2018
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
318
319
320
321
322
323
324
325
326
···
407
下一页
2021年5月22日
c语言函数式宏、逗号表达式
摘要: c语言函数式宏、逗号表达式 一般由逗号运算符连接的两个表达式“a, b”在语法上可以视为一个表达式,在表达式后面添加分号,就构成了表达式语句。 #include <stdio.h> #define puts_alert(str) (putchar('\a'), puts(str)) int main
阅读全文
posted @ 2021-05-22 09:50 小鲨鱼2018
阅读(363)
评论(0)
推荐(0)
2021年5月21日
c语言 8-3
摘要: 1、 #include <stdio.h> #define swap(type, a, b) {type tmp = a; a = b; b = tmp;} int main(void) { int x = 5, y = 10; printf("initial value x = %d\n", x)
阅读全文
posted @ 2021-05-21 23:16 小鲨鱼2018
阅读(114)
评论(0)
推荐(0)
c语言 8-2
摘要: 定义函数式宏,返回两个数中的最大值。 1、 #include <stdio.h> #define max(x, y) ((x > y) ? (x) : (y)) int main(void) { int a, b, c, d; puts("please input four integers.");
阅读全文
posted @ 2021-05-21 22:45 小鲨鱼2018
阅读(105)
评论(0)
推荐(0)
c语言 8-1
摘要: 定义一个函数式宏diff(x, y),返回x, y的差。 1、 #include <stdio.h> #define diff(x, y) ((x) - (y)) int main(void) { int a, b; puts("please input two integers."); print
阅读全文
posted @ 2021-05-21 22:24 小鲨鱼2018
阅读(261)
评论(0)
推荐(0)
c语言中使用函数式宏返回不同数据类型的值的平方
摘要: c语言中使用函数式宏返回不同数据类型的值的平方。 1、 #include <stdio.h> #define sqr(x) ((x) * (x)) int main(void) { int a; puts("please input an integer."); printf("a = "); sc
阅读全文
posted @ 2021-05-21 22:11 小鲨鱼2018
阅读(283)
评论(0)
推荐(0)
c语言中使用十进制、二进制、八进制和十六进制输出0到65535的整数。
摘要: 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
阅读(528)
评论(0)
推荐(0)
c语言中printf函数输出十进制、八进制和十六进制数
摘要: 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
阅读(3171)
评论(0)
推荐(0)
c语言 7-5
摘要: 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
阅读(86)
评论(0)
推荐(0)
c 语言7-4
摘要: 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
阅读(112)
评论(0)
推荐(0)
c语言 7-3
摘要: 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
阅读(80)
评论(0)
推荐(0)
上一页
1
···
318
319
320
321
322
323
324
325
326
···
407
下一页
公告