摘要: 1、 #include <stdio.h> #define swap(type, x, y) type tmp = x; x = y; y = tmp; int main(void) { int x = 10, y = 5; swap(int, x, y); printf("x = %d\n", x 阅读全文
posted @ 2021-05-24 18:39 小鲨鱼2018 阅读(49) 评论(0) 推荐(0) 编辑
摘要: 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."); printf("a = "); scanf( 阅读全文
posted @ 2021-05-24 18:29 小鲨鱼2018 阅读(63) 评论(0) 推荐(0) 编辑
摘要: c语言 8-1 1、 #include <stdio.h> #define diff(x, y) ((x) - (y)) int main(void) { int a, b; puts("please input two integers."); printf("a = "); scanf("%d" 阅读全文
posted @ 2021-05-24 18:09 小鲨鱼2018 阅读(353) 评论(0) 推荐(0) 编辑
摘要: c语言中函数、函数式宏例子 返回一个数的平方。 1、函数 #include <stdio.h> int sqr_int(int x) { return x * x; } double sqr_double(double x) { return x * x; } int main(void) { in 阅读全文
posted @ 2021-05-24 13:07 小鲨鱼2018 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> int main(void) { int i, j, ch; int cnt[10] = {}; while((ch = getchar()) != EOF) { if(ch > '0' && ch < '9') { cnt[ch - '0']++; } 阅读全文
posted @ 2021-05-24 12:20 小鲨鱼2018 阅读(96) 评论(0) 推荐(0) 编辑
摘要: c语言中数字字符计数 1、 #include <stdio.h> int main(void) { int i, ch; int cnt[10] = {}; while((ch = getchar()) != EOF) { switch(ch) { case '0': cnt[0]++; break 阅读全文
posted @ 2021-05-24 10:54 小鲨鱼2018 阅读(482) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> int main(void) { int ch; int rows = 0; while((ch = getchar()) != EOF) { switch(ch) { case '\n': rows++; break; } } printf("numbe 阅读全文
posted @ 2021-05-24 09:10 小鲨鱼2018 阅读(57) 评论(0) 推荐(0) 编辑