int max(int a, int b){return a>b?a:b;}
int min(int a, int b){return a<b?a:b;}
int add(int a, int b){return a+b;}
int sub(int a, int b){return a-b;}
int mul(int a, int b){return a*b;}
int div(int a, int b){return a/b;}
int main()
{
int (*fp[6])(int, int) = {max, min, add, sub, mul, dic};
char *fname[6] = {"max", "min", "add", "sub", "mul", "dic"};
int x, y=1, i;
printf("the six functions located at:\n");
printf("0x%04X 0x%04X 0x%04X 0x%04X 0x%04X 0x%04X\n",
max, min, add, sub, mul, dic);
printf("the function-pointer point to:\n");
for (i=0; i<6; i++)
printf("[%d]: 0x%04X -> 0x%04X\n", i, &fp[i], *fp[i]);
printf("\n");
while (1)
{
printf("Please input 2 number, x and y: ");
scanf("%d%d", &x, &y);
if (y==0) break;
for (i=0; i<6; i++) {
printf("%s(%d, %d) = %d\n", fname[i], x, y, (*fp[i])(x, y));
}
}
return 0;
}
int min(int a, int b){return a<b?a:b;}
int add(int a, int b){return a+b;}
int sub(int a, int b){return a-b;}
int mul(int a, int b){return a*b;}
int div(int a, int b){return a/b;}
int main()
{
int (*fp[6])(int, int) = {max, min, add, sub, mul, dic};
char *fname[6] = {"max", "min", "add", "sub", "mul", "dic"};
int x, y=1, i;
printf("the six functions located at:\n");
printf("0x%04X 0x%04X 0x%04X 0x%04X 0x%04X 0x%04X\n",
max, min, add, sub, mul, dic);
printf("the function-pointer point to:\n");
for (i=0; i<6; i++)
printf("[%d]: 0x%04X -> 0x%04X\n", i, &fp[i], *fp[i]);
printf("\n");
while (1)
{
printf("Please input 2 number, x and y: ");
scanf("%d%d", &x, &y);
if (y==0) break;
for (i=0; i<6; i++) {
printf("%s(%d, %d) = %d\n", fname[i], x, y, (*fp[i])(x, y));
}
}
return 0;
}