编写三个函数:求两个整数的最大值、最小值、和。分别用这三个函数作为实参,再写一个计算函数compute,对两个整数进行各种计算。其中一个形参为指向具体算法函数的指针。

函数接口定义:
int max(int a, int b);
int min(int a, int b);
int sum(int a, int b);
int compute(int a, int b, int(*func)(int, int));
裁判测试程序样例:

在这里给出函数被调用进行测试的例子。例如:
#include <iostream>
using namespace std;

int max(int a, int b);
int min(int a, int b);
int sum(int a, int b);
int compute(int a, int b, int(*func)(int, int));

int main()
{
int a, b, res;
 cin >> a >> b;
res = compute(a, b, & max);
cout << "Max of " << a << " and " << b << " is " << res << endl;
res = compute(a, b, & min);
cout << "Min of " << a << " and " << b << " is " << res << endl;
res = compute(a, b, & sum);
cout << "Sum of " << a << " and " << b << " is " << res << endl;
return 0;
}

/* 请在这里填写答案 */

输入样例:
3 5
输出样例:
Max of 3 and 5 is 5
Min of 3 and 5 is 3
Sum of 3 and 5 is 8
主要内容:指向函数的指针的运用

int max(int a, int b)
{
	return a>b?a:b;
}
int min(int a, int b)
{
	return a>b?b:a;
}
int sum(int a, int b)
{
	return a+b;
}
int compute(int a, int b, int(*func)(int, int))
{
	return (*func)(a,b);
}