版权声明:转载请注明来源~ https://blog.csdn.net/Lth_1571138383/article/details/80536226
/*
本程序应 习题 5 建立。
题目要求: 编写一个函数 larger_of() ,
该函数把两个double类型变量的替换为较大的值。
注: 是将两个变量中的最大值,赋值给两个变量。
*/
#include<stdio.h>
void larger_of(double *, double *);
int main(void)
{
double one = 0;
double two = 0;
printf("Please input two numbers :");
scanf_s("%lf %lf", &one, &two);
larger_of(&one, &two);
printf("Test print : The first value is %lf , and the second value is %lf .\n", one, two);
printf("Bye !\n");
getchar();
getchar();
return 0;
}
void larger_of(double *o, double *t)
{
double b_n = 0; // Biggest value 最大值。
b_n = (*o > *t) ? *o : *t; // 赋值最大值。
*o = b_n;
*t = b_n;
// 之所以不是 return 0 是因为那样写编译器总是会警告 void 的返回值默认为 int 。
return;
}