|
发表于 2004-12-31 14:36:06
|
显示全部楼层
[code:1]
#include <stdio.h>
void process(int,int,int (*)(int,int));
main()
{
int max(int,int);
int min(int,int);
int add(int,int);
// int (*fun)();
int a,b;
printf("情输入a和b两个数:");
scanf("%d%d",&a,&b);
printf("max= ");
process(a,b,max);
printf("min= ");
process(a,b,min);
printf("sum= ");
process(a,b,add);
}
max(int x,int y)
{
int z;
if(x>y)
z=x;
else if(x<y)
z=y;
return(z);
}
min(int x,int y)
{
int z;
if(x<y)
z=x;
else if(x>y)
z=y;
return(z);
}
add(int x,int y)
{
int z;
z=x+y;
return(z);
}
void process(int x,int y,int (*fun)(int x,int y))
{
int result;
result=(*fun)(x,y);
printf("%d\n",result);
}
[/code:1] |
|