//输入两个数,得出这两个数的最大值,最小值,和
#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
#include<math.h>
int max1(int x, int y);
int min1(int x, int y);
int add(int x, int y);
int process(int x, int y, int(*fun)(int, int));
int main()
{
int a, b;
printf("Enter a and b: ");
scanf("%d %d", &a, &b);
printf("max = ");
**process(a, b, max1);**//函数的调用
printf("min = ");
**process(a, b, min1);**
printf("sum = ");
**process(a, b, add);**
getchar();
getchar();
return 0;
}
int max1(int x, int y)
{
if (x > y)
{
printf(“max = %d”, x);
}
else
{
printf(“min = %d”, y);
}
return 0;
}
int min1(int x, int y)
{
if (x > y)
{
printf(“min = %d”, y);
}
else
{
printf(“max = %d”, x);
}
return 0;
}
int add(int x, int y)
{
int z;
z = x + y;
printf(“sum = %d”, z);
return 0;
}
**int process(int x, int y, int(fun)(int, int)) //声明(类型)(fun)(参数)
{
int a;
a = (*fun)(x, y);
return a;
}