摘要: 1、 #include <stdio.h> int gcd(int x, int y) { int max, min, tmp; if(x != y) { max = x > y ? x : y; min = x > y ? y : x; tmp = max % min; if(tmp != 0) 阅读全文
posted @ 2021-05-22 23:42 小鲨鱼2018 阅读(46) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> int fac(int x) { if(x > 0) return x * fac(x - 1); else return 1; } int main(void) { int a, b; puts("please input two integers.") 阅读全文
posted @ 2021-05-22 23:22 小鲨鱼2018 阅读(54) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> int fac(int x) { int i, fac = 1; if(x > 0) { for(i = x; i > 0; i--) fac *= i; } else fac = 1; return fac; } int main(void) { int 阅读全文
posted @ 2021-05-22 19:19 小鲨鱼2018 阅读(77) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑