[求助]大家看看这个笔试题,分析下
#include<stdio.h>
int inc(int a)
{
return(++a);
}
int multi(int*a,int*b,int*c)
{
return(*c=*a**b);
}
typedef int(FUNC1)(int in);
typedef int(FUNC2) (int*,int*,int*);
void show(FUNC2 fun,int arg1, int*arg2)
{
INCp=&inc;
int temp =p(arg1);
fun(&temp,&arg1, arg2);
printf("%d\n",*arg2);
}
main()
{
int a;
show(multi,10,&a);
return 0;
}
这是一道化为的笔试题。答案是110。
对这程序我有很多疑问。特来请教大家!
第一个,我运行时在这句INCp=&inc;出现了错误,但我不知道怎么修改。这是第一个请大家帮助的。
第二,typedef int(FUNC1)(int in);
typedef int(FUNC2) (int*,int*,int*);这2句话中用typedef定义类型,是怎么定义的?
第三,函数void show(FUNC2 fun,int arg1, int*arg2)是实现什么功能的阿?能不能帮我细致分析下。
谢谢大家!
----------------解决方案--------------------------------------------------------
1.#typedef int(*INC)(int i);
2.将FUN2定义为函数multi类型!!
3.
INCp=&inc;-------------求inc地址可以直接写成inc!这样写也对!!
int temp =p(arg1);------求inc(arg1)的值!
fun(&temp,&arg1, arg2);------------求函数multi((&temp,&arg1, arg2)的值(计算*arg2的值)
printf("%d\n",*arg2);----------------输出arg2的值。。。!
----------------解决方案--------------------------------------------------------
我怎么运行时出错阿!
在INCp=&inc;这句出错。
INC什么意思呢?是不是没有包含必要的头文件呢?
----------------解决方案--------------------------------------------------------
上面不是已经给出答案了吗!!晕!!
----------------解决方案--------------------------------------------------------