|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
void main
{
int max(int, int);
int min(int, int);
int add(int, int);
void process(int, int, int(*fun)());
int a, b;
printf("Endter a and b:");
scanf("%d %d", &a, &b);
printf("max = ");
process(a, b, max);
printf("min = ");
process(a, b, min);
printf("add = ");
process(a, b, add);
}
int max(int x,int y)
{
int z;
if(x > y)
{
z = x;
}
else
{
z = y
}
return z;
}
程序没有写完
怎么样调动process函数能使得他每次实现不同的功能呢
可以的话把程序写出来
谢谢啦!!
好久都不玩c了,现在手头上也编译不了
随手写了一段python代码 你参考一下:
- def max(a,b):
- return a
- def min(a,b):
- return b
- def add(a,b):
- return a+b
- def process(a,b,fun):
- return fun(a,b)
- print(process(4,5,max))
- print(process(4,5,min))
- print(process(4,5,add))
复制代码
运行效果:
D:\wp>py wp2.py
4
5
9
|
|