|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
void main()
{
double a, b, result;
printf("Input two numbers:");
scanf("%ld%ld", a, b);
double maximum(double a, double b);
double minimum(double a, double b);
double add(double a, double b);
double multiple(double a, double b, double (*p)());
result = multiple(a, b, maximum);
printf("max = %ld", result);
result = multiple(a, b, minimum);
printf("min = %ld", result);
result = multiple(a, b, add);
printf("add = %ld", result);
}
double maximum(double a, double b)
{
if(b > a)
{
a = b;
}
return a;
}
double minimum(double a, double b)
{
if(b < a)
{
a = b;
}
return a;
}
double add(double a, double b)
{
return(a + b);
}
double multiple(double a, double b, double (*p)())
{
return (*p)(a, b);
}
|
|