c语言程序填空 下面程序是计算sum=1+(1+1/2)+(1+1/2+1/3)+…(1+1/2
c语言程序填空 下面程序是计算sum=1+(1+1/2)+(1+1/2+1/3)+…(1+1/2
日期:2015-10-13 16:13:22 人气:1
#include #include void main(){ float sum = 0; float sub_sum = 0; int n = 3; for(int i = 1;i<=n;i++) { sub_sum += 1.0/i; sum += sub_sum; } printf("sum = %.4f\r\n",sum); system("pause");}