上一页 1 ··· 277 278 279 280 281 282 283 284 285 ··· 367 下一页
摘要: c语言中利用递归求非负整数的阶乘。 1、 #include <stdio.h> int factorial(int x) { if(x > 0) return x * factorial(x - 1); else return 1; } int main(void) { int a; puts("p 阅读全文
posted @ 2021-05-22 19:01 小鲨鱼2018 阅读(271) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> enum info { Gender, Season, Age, Invalid}; void gender(void) { puts("male.\n"); } void season(void) { puts("summer.\n"); } void 阅读全文
posted @ 2021-05-22 17:35 小鲨鱼2018 阅读(64) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> #define NUMBER 5 void bsort(int x[], int n) { int i, j; for(i = 0; i < n - 1; i++) { for(j = 1; j < n - i; j++) { if(x[j - 1] > 阅读全文
posted @ 2021-05-22 17:25 小鲨鱼2018 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> enum animal {Dog, Cat, Monkey, Invalid}; void dog(void) { puts("wang wang\n"); } void cat(void) { puts("miao miao\n"); } void mo 阅读全文
posted @ 2021-05-22 16:25 小鲨鱼2018 阅读(41) 评论(0) 推荐(0) 编辑
摘要: c语言中冒泡排序法。 1、升序排列 #include <stdio.h> #define NUMBER 5 void bsort(int x[], int n) { int i, j; for(i = 0; i < n - 1; i++) { for(j = n - 1; j > i; j--) { 阅读全文
posted @ 2021-05-22 10:47 小鲨鱼2018 阅读(587) 评论(0) 推荐(0) 编辑
摘要: c语言函数式宏、逗号表达式 一般由逗号运算符连接的两个表达式“a, b”在语法上可以视为一个表达式,在表达式后面添加分号,就构成了表达式语句。 #include <stdio.h> #define puts_alert(str) (putchar('\a'), puts(str)) int main 阅读全文
posted @ 2021-05-22 09:50 小鲨鱼2018 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(93) 评论(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."); 阅读全文
posted @ 2021-05-21 22:45 小鲨鱼2018 阅读(70) 评论(0) 推荐(0) 编辑
摘要: 定义一个函数式宏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 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(238) 评论(0) 推荐(0) 编辑
上一页 1 ··· 277 278 279 280 281 282 283 284 285 ··· 367 下一页