Home   Cover Cover Cover Cover
 

if statement

/csbook/solutions/06/A01.cs
using System;

class Test {
  
  static int Max(int a, int b, int c) {
    if (a > b)
      if (a > c) // a > b && a > c
        return a;
      else       // c >= a && a > b
        return c;
    else         // b >= a
      if (b > c) // b >= a && b > c
        return b;
      else       // c >= b && b >= a
        return c;
  }

  static void Main() {
    Console.WriteLine(Max(1, 2, 3));
    Console.WriteLine(Max(2, 1, 3));
    Console.WriteLine(Max(1, 2, 2));
    Console.WriteLine(Max(2, 2, 3));
  }
}