C语言编程序:计算数列1+1/2+1/3+1/4+...+1/100的和并输出 帮一下 吧

如题所述

#include<stdio.h>
int main()
{int i;
 float s=0;
 for(i=1;i<=100;i++)
   s+=1.0/i;
 printf("%g\n",s);
 return 0;
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-01-21
最后输出一定要%g吗,用%f行不行
相似回答