1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-27 08:26:20 +00:00
202401-programming-assignments/【实践课外】11.函数2/6-1 计算A[n]=1_(1 + A[n-1]).md

39 lines
654 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 6-1 计算A[n]=1/(1 + A[n-1])
函数 fun 的功能是:根据整型形参 n计算某一数据项的值。
A[1]=1, A[2]=1/(1 + A[1]), A[3]=1/(1 + A[2]), …,A[n]=1/(1 + A[n-1])
例如,若 n=10则应输出A10=0.617977。
### 函数接口定义:
```c++
float fun(int n);
```
其中`n`是用户传入的参数,函数须返回第`n`项的值。
### 裁判测试程序样例:
```c++
#include <stdio.h>
float fun(int n);
int main( )
{ int n ;
scanf("%d", &n ) ;
printf("A%d=%f\n", n, fun(n) ) ;
return 0;
}
/* 请在这里填写答案 */
```
### 输入样例:
```in
10
```
### 输出样例:
```out
A10=0.6180
```