ylbtech-Arithmetic:Console-算法[do while]-XX |
1.A,Demo(案例) |
1.B,Solution(解决方案) |
using System; namespace ConsoleApplication1 { class Program { /// <summary> /// ylb: do while /// </summary> /// <param name="args"></param> static void Main(string[] args) { Console.Write(fun(2.5)); } /// <summary> /// fun /// </summary> /// <param name="x"></param> /// <returns></returns> static double fun(double x) { double f, t; int n; f=1.0+x; t=x; n=1; do { n++; t *= x / n; //这儿构思很其巧妙 f += t; } while (Math.Abs(t) >= Math.Pow(10,-6)); return f; } } }
1.C,Execution Result(运行结果) |
12.1824938304434请按任意键继续. . .
![]() |
作者:ylbtech 出处:http://ylbtech.cnblogs.com/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 |
Arithmetic:fun1(do while),布布扣,bubuko.com
原文:http://www.cnblogs.com/ylbtech/p/3624912.html