作业帮 > 综合 > 作业

已知:S=1+1/2+1/3+…+1/n,输入n的值,输出S的值,画出算法框图

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/28 04:46:27
已知:S=1+1/2+1/3+…+1/n,输入n的值,输出S的值,画出算法框图
#include "stdio.h"
void main()
{
    int i, n;
    double s = 0;
    printf("input value of n : ");
    scanf("%d", &n);
    for(i=1; i<=n; i++)
        s += 1.0 / i;
    printf("s = %.6lf", s);
}