![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/2f3aa675d7b2865e2c4c1e957427a4c1.png)
#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 x, y;
int iupt = 1;
int ret = 0;
int(*pf[5])(int x, int y) = { 0, add, sub, mul, div };
while (iupt)
{
printf("***************************\n");
printf(" 1:add 2:sub \n");
printf(" 3:mul 4:div \n");
printf("***************************\n");
printf("请选择:");
scanf("%d", &iupt);
if ((iupt <= 4 && iupt >= 1))
{
printf("请输入操作数:");
scanf("%d %d", &x, &y);
ret = (*pf[iupt])(x, y);
}
else
{
printf("输入有错误\n");
}
printf("ret = %d\n", ret);
}
return 0;
}