Most efficient way to find the greatest of three ints

前端 未结 14 1260
离开以前
离开以前 2020-12-30 07:58

Below is my pseudo code.

function highest(i, j, k)
{
  if(i > j && i > k)
  {
    return i;
  }
  else         


        
14条回答
  •  不思量自难忘°
    2020-12-30 08:43

    In C# finding the greatest and smallest number between 3 digit

    static void recorrectFindSmallestNumber()
    {
    int x = 30, y = 22, z = 11;
    if (x < y)
    {
    if (x < z)
    {
    Console.WriteLine("X is Smaller Numebr {0}.", x);
    }
    else
    {
    Console.WriteLine("z is Smaller Numebr {0}.", z);
    }
    }
    else if (x > y)
    {
    if (y < z)
    {
    Console.WriteLine("y is Smaller number.{0}", y);
    }
    else
    {
    Console.WriteLine("z is Smaller number.{0}", z);
    }
    }
     else
    {
    
    }
    }
    

    =================================================================

    static void recorrectFindLargeNumber()
    {
    int x, y, z;
    Console.WriteLine("Enter the first number:");
    x = int.Parse(Console.ReadLine());
    Console.WriteLine("Enter the second number:");
    y = int.Parse(Console.ReadLine());
    Console.WriteLine("Enter the third nuumnber:");
    z = int.Parse(Console.ReadLine());
    if (x > y)
    {
    if (x > z)
    {
    Console.WriteLine("X is Greater numbaer: {0}.", x);
    }
    else
    {
    Console.WriteLine("Z is greatest number: {0}.", z);
    }
    }
    else if (x < y)
    {
    if (y > z)
    {
    Console.WriteLine("y is Greater Number: {0}", y);
    }
    else 
    {
    Console.WriteLine("Z is Greater Number; {0}", z);                
    }
    }
    else
    {
                    
    }
    }
    

提交回复
热议问题