#include <stdio.h>
//函数指针数组
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 m = 0, n = 0, i = 0, ret = 0;
scanf("%d %d", &m, &n);
int(*pfarr[4])(int, int) = { Add,Sub,Mul,Div };
for (i = 0; i < 4; i++)
{
ret = (*pfarr[i])(m, n);
printf("%d\n", ret);
}
return 0;
}
C语言——函数指针数组
最新推荐文章于 2024-08-22 19:20:50 发布