1+1/2+1/3+……+1/n(n<=100) (C语言)

#include "stdio.h"
main()
{
    float i,j,sum,n;
    sum=0,j=1;
    while(j<=100){
        n=1/j;
        sum+=n;
        j++;
    }
    printf("最后结果为:%f",sum); 
}

你可能感兴趣的:(算法,数据结构)