#include <stdio.h>


/*
函数指针、函数指针数组
*/
int add(int x, int y)
{
    return x+y;
}
int sub(int x, int y)
{
    return x-y;
}
int mul(int x, int y)
{
    return x*y;
}
int div(int x, int y)
{
    return x/y;
}

int main()
{
    // int (*)(int, int);//函数指针类型
    // int (*pfArr[10])(int, int) = {0};//函数指针数组,pfArr就是函数指针数组
    int input = 0;
    do {
        int (* pfArr[5])(int, int) = {NULL,add,sub,mul,div};
        int x = 0;
        int y = 0;
        int ret = 0;
        printf("请选择:");
        scanf("%d", &input);
        printf("输入两个数");
        scanf("%d %d", &x, &y);
        ret = (pfArr[input])(x, y);
        printf("结果=%d\n", ret);
    } while (input);
	return 0;
}