“21天好习惯”第一期-16
作者:互联网
求n分之一序列的前n项和
#include <stdio.h>
int main()
{
int N;
int a=1;
float s=0.0;
scanf("%d",&N);
while (a<=N)
{
s=s+1.0/a;
a++;
}
printf("sum = %.6f",s);
return 0;
}
5
sum = 2.283334
Process returned 0 (0x0) execution time : 1.172 s
Press any key to continue.
100
sum = 5.187378
Process returned 0 (0x0) execution time : 2.607 s
Press any key to continue.
标签:天好,21,16,int,0x0,key,Press,any,returned 来源: https://blog.csdn.net/weixin_63186233/article/details/121226547