请编程计算1+1/2+1/3+1/4+…+1/10

如题所述

float s = 0;
int i;
for (i = 0; i <= 10; i++) s += 1.0/i;
printf("%d", s);追问

完整的啊

追答#include <stdio.h>

int main()
{
    float s = 0;
    int i;
    for (i = 0; i <= 10; i++) s += 1.0/i;
    printf("%f", s);
    return 0;
}
温馨提示:内容为网友见解,仅供参考
无其他回答

1+1\/2+1\/3+1\/4+.+1\/10等于多少?
= 1 + (1\/2 + 1\/3 + 1\/6) + (1\/4 + 1\/5 + 1\/10) + 1\/7 + 1\/8 + 1\/9 = 1 + 1 + (1\/2 + 1\/3 - 1\/6) + (1\/4 + 1\/5 + 1\/10)= 1 + 1 + (1 - 1\/6) + (1\/2 + 1\/4 + 1\/5 + 1\/10)= 1 + 1 + 5\/6 + (1\/2 + 1\/4 + 2\/10)=...

c++问题:1+1\/2+1\/3+1\/4+1\/5+1\/6+1\/7+1\/8+1\/9+1\/10=?
int main() { double sum = 0.0;for (int i=1;i<=10;i++) { sum += 1.0\/(double)i;} cout << "the sum is " << sum << endl;return 0;}

一加二分之一加三分之一加四分之一...加十分之一,求值在哪两个自然...
原式S=1+1\/2+1\/3+1\/4……+1\/10 (1)式 =1+(1-1\/2)+(1-2\/3)+(1-3\/4)+……+(1-9\/10)=10-1\/2-2\/3-3\/4……-9\/10 (2)式 将(1)、(2)式相加,得 2S= 11-1\/3-1\/2-3\/5-2\/3-5\/7-3\/4-7\/9-4\/5 化简一下,即是:2S = 10 - 1\/2 - 7\/5 ...

1+1\/2+1\/3+1\/4+1\/5……
1+1\/2+1\/3+1\/4+1\/5+1\/6+1\/7+1\/8+1\/9+1\/10 =1+(1\/2+1\/3+1\/6)+(1\/4+1\/5+1\/10)+1\/7+1\/8+1\/9 =1+1+11\/20+1\/8+1\/7+1\/9 =1+1+27\/40+1\/9+1\/7 =1+1+283\/360+1\/7 =1+1+2341\/2520 =1+4861\/2520 ≈2.92896 ...

c语言课程设计 1-1\/2+1\/3-1\/4+…+1\/10的程序编写
include "stdio.h"main(){ int flag=1;float sum=0,i;for(i=1;i<=10;i++){ sum+=(1\/i)*flag;flag=-flag;} printf("%f ",sum);}

用JAVA的For循环编写1+1\/2+1\/3+1\/4+1\/5+1\/6+1\/7+1\/8+1\/9+1\/10
class jia{ public static void main(String[] args){ float sum = 0;for (int i = 1;i <= 100;i++) { sum+=(float)1\/i;} System.out.println(sum);} } 我把上面的哥们的东西改了下,估计更好看一些!运行没错。

Java编程:计算1+1\/2+1\/3+1\/4+···+1\/n,加到多少项时,其和可超过10...
public static void main(String args[]) { double n=1;double sum=0;while(sum<10){ sum=sum+1\/n;System.out.println("n="+n);System.out.println("sum="+sum);n++;} System.out.println("加到第"+(n-1)+"项时满足sum>10");} } n=12367.0 sum=10.000043008275778 加到第...

C语言 分数计算怎么编 如1+1\/2+1\/3+1\/4+……1\/n ?
include<stdio.h> int main(void){ int n;scanf("%d",&n);int i;double sum=0;double sign=1.0;for(i=1;i<=n;i++){ sum=sum+sign\/i;sign=-sign;} printf("f(%d)=%f\\n",n,sum);return 0;}

1+1\/2+1\/3...到1\/n的和是多少?
一开始我们先设原式为:A=1+1\/2+1\/3+1\/4+1\/5+1\/6+1\/7+1\/8+1\/9+1\/10+1\/11+1\/12+1\/13+1\/13+……然后再设另一式为:B=1+1\/2+(1\/4+1\/4)+(1\/8+1\/8+1\/8+1\/8)+(1\/16+1\/16+1\/16+1\/16+1\/16+……..所以A >B ………..a =>B= 1+1\/2+1\/4×...

c语言求1+1\/2+1\/4+1\/6+1\/8+1\/10+1\/12+1\/14+1\/16+1\/18+1\/20?
int i;float t,s=1;for (i=1;i<=10;i++){ t = 1.0\/(2*i);s += t;printf("%d %.4f %.4f\\n",i,t,s);} printf("%f\\n",s);

相似回答
大家正在搜