*/
*Copyright(c)2013,烟台大学计算机学院学生
*All rights reserved.
*文件名称:见标题

*作者:张凯
*完成日期:2013年 10 月29 日
*版本号:v1.0
*求解的问题:
*/


#include <iostream>
#include<cmath>
using namespace std;
int main()
{
    double s=0,p=1;
    int i=0,t=1;

     while(i<=8)
    {
        s=s+t*p;
        t=-t;
        p=p*0.5;

          i++;
    }
    cout<<"s="<<s<<endl;

    return 0;
}

运行结果 (如下图)

                                 求 1-1/(2^1)+ +1/(2^8)

心得体会:不用pow更能扩展自己的思维

相关文章:

  • 2022-12-23
  • 2022-02-17
  • 2021-09-05
  • 2021-07-10
  • 2021-09-05
  • 2022-12-23
  • 2021-05-11
  • 2021-12-12
猜你喜欢
  • 2021-08-15
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
  • 2022-12-23
  • 2022-02-01
相关资源
相似解决方案