Chinaunix首页 | 论坛 | 博客
  • 博客访问: 22316
  • 博文数量: 10
  • 博客积分: 251
  • 博客等级: 二等列兵
  • 技术积分: 125
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-10 16:30
文章分类
文章存档

2011年(10)

我的朋友
最近访客

分类: 嵌入式

2011-06-27 22:48:30

  1. ///

  2. /// divide and conquer

  3. ///

  4. /*
  5.  * 不要事事从头做起。要尽可能利用FCL标准库提供的函数而不是生成新函数,
  6.  * 从而减少程序开发时间,避免引入编程错误,并为好的程序性能做出贡献。
  7.  */

  8. using System;


  9. public class MaximumFinderTest
  10. {
  11.     public static void Main(string[] args)
  12.     {
  13.         MaximumFinder maximumFinder = new MaximumFinder();
  14.         maximumFinder.DetermineMaximum();
  15.         
  16.             
  17.         Console.Write("Press any key to continue . . . ");
  18.         Console.ReadKey(true);
  19.     }
  20. }

  21. //using System;

  22.     
  23. public class MaximumFinder
  24. {
  25.     public void DetermineMaximum()
  26.     {
  27.         Console.WriteLine("Enter three floating-point values,\n"
  28.          + " pressing 'Enter' after each one:");
  29.         
  30.         double number1 = Convert.ToDouble(Console.ReadLine());
  31.         double number2 = Convert.ToDouble(Console.ReadLine());    
  32.         double number3 = Convert.ToDouble(Console.ReadLine());    
  33.         
  34.         double result = Maximum(number1,number2,number3);
  35.         
  36.         Console.WriteLine("The maximum is:{0}.",result);
  37.     }
  38.     
  39.     public double Maximum(double x,double y,double z)
  40.     {
  41.         double maximumValue = x;
  42.         
  43.         if(y > maximumValue)
  44.             maximumValue = y;
  45.         if(z > maximumValue)
  46.             maximumValue = z;
  47.         
  48.         return maximumValue;
  49.     }
  50. }
阅读(1019) | 评论(0) | 转发(0) |
0

上一篇:class And object_Three

下一篇:最近那点事

给主人留下些什么吧!~~