指向函数指针问题.!
#include<stdio.h>main(){
int max(int,int);
int min(int,int);
int sum(int,int);
int growth(int,int,int (*p)());
int a,b,(*p)();
p=growth;
scanf("%d%d",&a,&b);
printf("max=%d\n",(*p)(a,b,max));
printf("min=%d\n",p(a,b,min));
printf("sum=%d\n",p(a,b,sum));
}
///////////////////////////////////////////
int max(int a,int b){
if(a>b) return a;
else return b;
}
int min(int a,int b){
if(a>b) return b;
else return a;
}
int sum(int a,int b){
int c;
c=a+b;
return c;
}
int growth(int a,int b,int p(int,int)){
int c=0;
c=p(a,b);
return c;
}
为什么只能在linux系统下运行.!
感觉我的思路也没错.!
p=growth; 尤其是这句.!