#include void main() { float result; int i=1; do{ result+=1.0/i; i++; }while(i<=100); printf("result=%f",result); } 麻烦采纳,谢谢!
#include double sum(int n){//1/k(前n项的和) double s=0; for(int i=1;i<=n;i++){ s+=1.0/i; } return s; } void main() { printf("1+1/2+1/3+…+1/99+1/100=%f \n",sum(100)); }