Advertisement
remote87

Biggest Of Three Numbers

Sep 5th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Globalization;
  7.  
  8. namespace _05.TheBiggestOfThreeNumbers
  9. {
  10.     class TheBiggestOfThreeNumbers
  11.     {
  12.         static void Main()
  13.         {
  14.             Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
  15.             // First uncommen this:
  16.             //double a = 0;
  17.             //double b = 0;
  18.             //double c = 0;
  19.  
  20.             //Console.Write("Enter first number a: ");
  21.             //double.TryParse(Console.ReadLine(), out a);
  22.             //Console.Write("Enter second number b: ");
  23.             //double.TryParse(Console.ReadLine(), out b);
  24.             //Console.Write("Enter third number c: ");
  25.             //double.TryParse(Console.ReadLine(), out c);
  26.  
  27.             // This is the first way to do it:
  28.             //Console.WriteLine("The biggest number is {0}.", (Math.Max(Math.Max(a, b), c)));
  29.  
  30.             // This is the second way to do it:
  31.             //if ((a > b) && (a > c))
  32.             //{
  33.             //   Console.WriteLine(a);
  34.             //}
  35.             //else
  36.             //{
  37.             //   if ((b > a) && (b > c))
  38.             //   {
  39.             //      Console.WriteLine(b);
  40.             //   }
  41.             //   else
  42.             //   {
  43.             //      Console.WriteLine(c);
  44.             //   }
  45.             //}
  46.  
  47.             // This is the third way to do it:
  48.             double max = double.MinValue;
  49.  
  50.             for (double i = 0; i < 3; i++)
  51.             {
  52.                 double num = double.Parse(Console.ReadLine());
  53.                 if (num > max)
  54.                 {
  55.                     max = num;
  56.                 }
  57.             }
  58.  
  59.             Console.WriteLine(max);
  60.  
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement