#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int average(int x, int y)
{ int z = x + (y-x)/2; //求两数平均值的函数式
return z;
}
int main()
{ int b=0;
int a=0;
int c=0;
printf(“输入两个操作数:>”);
scanf("%d %d",&a,&b);
c = average(a, b); //求平均值函数的调用
printf(“sum=%d\n”, c);
system(“pause”);
return 0;
}
运用函数调用法求两数的平均(C语言)
最新推荐文章于 2024-04-22 22:11:41 发布
该博客展示了一段C语言代码,定义了求两数平均值的函数,在主函数中获取用户输入的两个操作数,调用求平均值函数计算结果并输出,还使用system(“pause”)暂停程序。
&spm=1001.2101.3001.5002&articleId=88629536&d=1&t=3&u=d3cde95a1ff744099d3d8df2db3cddb7)
13万+

被折叠的 条评论
为什么被折叠?



