上一页 1 ··· 340 341 342 343 344 345 346 347 348 ··· 403 下一页
摘要: 1、c语言在函数中调用其他函数(计算四个数中的最大值) #include <stdio.h> int max2(int a, int b) { return (a > b) ? a : b; } int max4(int x, int y, int z, int p) { return max2(m 阅读全文
posted @ 2021-03-24 11:21 小鲨鱼2018 阅读(622) 评论(0) 推荐(0)
摘要: 1、c语言中定义函数和调用函数(计算int型整数的立方) #include <stdio.h> int cube(int a) { return a * a * a; } int main(void) { int n1; puts("please input an integer."); print 阅读全文
posted @ 2021-03-24 11:06 小鲨鱼2018 阅读(1301) 评论(0) 推荐(0)
摘要: 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 阅读(348) 评论(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 阅读(4019) 评论(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 阅读(991) 评论(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 阅读(3938) 评论(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 阅读(435) 评论(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 阅读(795) 评论(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 阅读(474) 评论(0) 推荐(0)
摘要: 1、虽然通过对象式宏来变更元素的数目非常方便,但是每次都需要对程序进行修改,然后重新编译执行。 我们可以定义一个比较大的数组,然后从头开始仅使用其中需要的部分。 #include <stdio.h> #define NUMBER 80 int main(void) { int i, j; int a 阅读全文
posted @ 2021-03-22 10:58 小鲨鱼2018 阅读(656) 评论(0) 推荐(0)
上一页 1 ··· 340 341 342 343 344 345 346 347 348 ··· 403 下一页