[第3章程序设计初步.pptVIP

  • 3
  • 0
  • 约4.3万字
  • 约 99页
  • 2017-01-06 发布于北京
  • 举报
[第3章程序设计初步

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 例3.12 用下面公式求π的近似值。π/4≈1-1/3+1/5-1/7+…直到最后一项的绝对值小于10-7为止。 #include iostream #include iomanip #include cmath using namespace std; int main( ) {int s=1; double n=1,t=1,pi=0; while((fabs(t))1e-7) { pi=pi+t; n=n+2; s=-s; t=s/n; } 3.14 编写循环结构的程序 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. pi=pi*4; cout″pi=″s

文档评论(0)

1亿VIP精品文档

相关文档