A36776. 给定程序中,函数fun的功能是根据形参i的值返回某个函数的值。当调用正确时,程序输出:x1=5.000000,x2=3.000000,x1*x1 +x1*x2=40.000000不得增行或删行,也不得更改程序的结构!#include <stdio.h>#include <stdlib.h>double f1(double x){ return x*x;}double f2(double x, d…
填空题
困难
知识点
题目描述
给定程序中,函数fun的功能是根据形参i的值返回某个函数的值。当调用正确时,程序输出:
x1=5.000000,x2=3.000000,x1*x1 +x1*x2=40.000000
不得增行或删行,也不得更改程序的结构!
#include <stdio.h>
#include <stdlib.h>
double f1(double x)
{
return x*x;
}
double f2(double x, double y)
{
return x*y;
}
/**********found**********/
__(1)__ fun(int i, double x, double y)
{
if(i==1)
{
/**********found**********/
return __(2)__(x);
}
else
{
/**********found**********/
return __(3)__(x,y);
}
}
main()
{
double x1=5, x2=3, r;
r = fun(1, x1, x2);
r += fun(2, x1, x2);
printf("\nx1=%f, x2=%f, x1*x1+x1*x2=%f\n",x1, x2, r);
system("pause");
}
参考答案
<p>1. 正确答案: double</p><p>2. 正确答案: f1</p><p>3. 正确答案: f2</p>
上一题
下一题