问答题

编写函数fun,其功能是:根据以下公式计算s,并将计算结果作为函数值返回,n通过形参传人。


例如,若n的值为11时,函数的值为1.833333。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
float fun(int n)


void main()

int n;
float s;
system("CLS");
printf("\nPlease enter N:");
scanf("%d",&n);
s=fun(n);
printf("The result is:%f\n",s);

【参考答案】

double fun(int n)
{
int i,sA=0·
fioat ......

(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)