/**有2个整数a,b,有用户输入1,2,或3,如输入1, 程序就给出a和b中大者,输入2,就给出a和b中小者, 输入3,就给出a和b的和**/ #include <stdio.h> #include <stdlib.h> int main() { int f(int x,int y,int (*p)(int ,int )); int max(int x,int y); int min(int x,int y); int sum(int x,int y); int a=34,b=-10; int n; scanf("%d",&n); if(n==1) f(a,b,max); if(n==2) f(a,b,min); if(n==3) f(a,b,sum); return 0; } int f(int x,int y,int (*p)(int ,int )) { int ss; ss=(*p)(x,y); printf("%d\n",ss); return 0; } int max(int x,int y) { int z; if(x>y) z=x; else z=y; return z; } int min(int x,int y) { int z; if(x>y) z=y; else z=x; return z; } int sum(int x,int y) { return x+y; }