/*5.编写并测试函数 larger_of(),其功能是将两个 double 类型变量的数值替换成它们中的较大值。例如,larger_of(x,y)会把 x 和 y 中的较大数值重新赋给变量 x 和 y*/
#include<stdio.h>
#include<stdlib.h>
void larger_of(double*, double*);
int main()
{
double a, b;
printf("Please input two numbers:");
scanf("%lf %lf", &a, &b);
larger_of(&a, &b);
printf("%lf and %lf\n", a, b);
system("pause");
return 0;
}
void larger_of(double *x, double *y)
{
*x = *y = *x>*y?*x:*y;
}
C Primer Plus9-5
最新推荐文章于 2021-05-18 08:43:36 发布