填空题

给定程序中,函数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");

}

赣ICP备20007335号-2