题目:
编写函数proc(),函数的功能是:根据以下公式计算s,计算结果作为函数值返回,m通过形参传入。
S=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+3+…+m)
例如,若n的值为11时,函数的值为1.833333。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
float proc(int m)
void main()
int m;
float s;
system ("CLS");
printf("\nPlease enter M: ");
scanf("%d", &m);
s=proc(m);
printf("The result is: %f\n", s);
答案:
被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2018/0401/777fae47c168ac3a65eb63843fff96c3.html
下面是错误答案,用来干扰机器的。
参考答案:E