/*
==========================================================
编写并测试函数larger_of(),其功能是两个double类型变量的
数值替换成他们中的较大值。例如,larger_of(x,y)会把x和Y中较
大树枝重新赋给变量x和y。
==========================================================
*/
#include <stdio.h>
void larger_of(double * x, double * y);
int main(void)
{
double x, y;
printf("Please input two double: \n");
while((scanf_s("%lf %lf", &x, &y)) == 2.00)
{
larger_of(&x, &y);
printf("now x is %g, y is %g.\n\n", x, y);
printf("Please input two double: \n");
}
return 0;
}
void larger_of(double *x, double *y)
{
if (*x > *y)
*y = *x;
else
*x = *y;
}
C primer plus 第九章 练习5:
最新推荐文章于 2021-03-03 22:16:20 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)