![](https://static.youtibao.com/asksite/comm/h5/images/m_q_title.png)
编写一个函数fun,它的功能是:根据以下公式求p的值,结果由函数值带回。m与n为两个正整数,且要求m>n
![](https://static.youtibao.com/asksite/comm/h5/images/solist_ts.png)
例如:m=12,n=8时,运行结果应该是495.000000。请在题目的空白处填写适当的程序语句,将该程序补充完整。
#include
#include
float fun (int m, int n)
{ int i;
double p=1.0;
for(i=1;i<=m;i++)();
for(i=1;i<=n;i++)();
for(i=1;i<=m-n;i++)p=p/i;
return p;}
main ()
{ clrscr();
printf ("p=%f\n",fun (12,8));}
程序运行后,如果输入精度0.0005,则程序输出为3.140578。
注意:部分源程序存在文件PROGl.C文件中。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <conio.h>
include <math.h>
include <stdio.h>
double fun(int n)
{
}
main()
{
clrscr();
printf("s=%f\n", fun(1000));
}
S=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+3+…+n)
例如:若n的值为11时,函数的值为1.833333。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <conio.h>
include <stdio.h>
include <string.h>
float fun(int n)
{
}
main()
{
int n;
float s;
clrscr();
printf("\nPlease enter N: ");
scanf("%d",&n);
s=fun(n);
printf("The result is:%f\n " , s);
}
例如,若n为1000时,程序输出应为:s=153.909064。
注意:部分源程序在文件PROGl.C中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fan的花括号中填入所编写的若干语句。
试题程序:
define M 4
include <stdio.h>
fun(int a[] [M])
{
}
main()
{
int arr[2][M]={5, 8, 3, 45, 76, -4, 12, 82};
printf("max=%d\n",fun(arr));
}
A.一个用于指向函数的指针变量,函数返回值的类型为int型
B.一个带回值类型为整型的函数名
C.一个用于指向整型数据的指针变量
D.一个带回值类型为指针类型的函数名
例如:若二维数组中的值为
1 3 5 7 9
2 9 9 9 4
6 9 9 9 8
1 3 5 7 0
则函数值为61。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<conio.h>
include<stdio.h>
define M 4
define N 5
int fun(int a [M][N])
{
}
main()
{
int aa[M][N]={{1,3,5,7,9},{2,9,9,9,4},
{6,9,9,9,8},{1,3,5,7,0}};
int i, j, y;
clrscr();
printf ("The original data is :\n ");
for(i=0; i<N;i++)
{for (j=0; j<N;j++)
printf("%6d ",aa[i][j]);
printf("\n ");
}
y=fun(aa);
printf("\nThe sun:%d\n ",y);
printf("\n");
}