上一页 1 ··· 304 305 306 307 308 309 310 311 312 ··· 367 下一页
摘要: 1、将函数的返回值作为参数传递给其他函数,计算平方差 #include <stdio.h> int sqr(int x) { return x * x; } int diff(int a, int b) { return (a > b ? a - b : b - a); } int main(voi 阅读全文
posted @ 2021-03-24 10:56 小鲨鱼2018 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 1、c语言中定义函数和调用函数(计算三个数中的最小值) #include <stdio.h> int min3(int a, int b, int c) { int min = a; if (b < min) min = b; if (c < min) min = c; return min; } 阅读全文
posted @ 2021-03-24 10:41 小鲨鱼2018 阅读(3617) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> int min2(int a, int b) { if (a < b) return a; else return b; } int main(void) { int n1, n2; puts("please input two integers!"); 阅读全文
posted @ 2021-03-24 10:24 小鲨鱼2018 阅读(854) 评论(0) 推荐(0) 编辑
摘要: 1、c语言中定义函数和调用函数(计算三个数中的最大值) #include <stdio.h> int max3(int a, int b, int c) { int max = a; if (b > max) max = b; if (c > max) max = c; return max; } 阅读全文
posted @ 2021-03-24 10:08 小鲨鱼2018 阅读(3592) 评论(0) 推荐(0) 编辑
摘要: 1、求两个数中的较大值 #include <stdio.h> int main(void) { int i, j, max; puts("please input two integer!"); printf("i = "); scanf("%d", &i); printf("j = "); sca 阅读全文
posted @ 2021-03-24 09:52 小鲨鱼2018 阅读(384) 评论(0) 推荐(0) 编辑
摘要: 1、函数定义和函数调用 #include <stdio.h> int max2(int a, int b) ## 函数头:返回类型, 函数名,形参声明a,形参声明b { if (a > b) return a; ## 函数体(复合语句) ## 函数定义 else return b; } int ma 阅读全文
posted @ 2021-03-24 09:26 小鲨鱼2018 阅读(633) 评论(0) 推荐(0) 编辑
摘要: 1、c语言中main函数和库函数 #include <stdio.h> int main(void) { /*.......*/ return 0; } 其中绿色部分称为main函数。 c语言程序中,main函数是必不可少的。程序运行的时候,会执行main函数的主体部分。 main函数中使用了pri 阅读全文
posted @ 2021-03-24 08:44 小鲨鱼2018 阅读(430) 评论(0) 推荐(0) 编辑
摘要: 1、虽然通过对象式宏来变更元素的数目非常方便,但是每次都需要对程序进行修改,然后重新编译执行。 我们可以定义一个比较大的数组,然后从头开始仅使用其中需要的部分。 #include <stdio.h> #define NUMBER 80 int main(void) { int i, j; int a 阅读全文
posted @ 2021-03-22 10:58 小鲨鱼2018 阅读(593) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> #define NUMBER 4 int main(void) { int i; int a[NUMBER]; int sum = 0; puts("please input the scores."); for (i = 0; i < NUMBER; i 阅读全文
posted @ 2021-03-21 18:29 小鲨鱼2018 阅读(71) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> int main(void) { int num, i = 0, sum = 0, tmp; puts("please input the num."); printf("num = "); scanf("%d", &num); while (i < nu 阅读全文
posted @ 2021-03-21 09:16 小鲨鱼2018 阅读(109) 评论(0) 推荐(0) 编辑
上一页 1 ··· 304 305 306 307 308 309 310 311 312 ··· 367 下一页