CryptoJones icon

InteviewQuestionForReddit

CryptoJones | PRO | 06/15/18 07:42:27 PM UTC | 0 ⭐ | 623 👁️ | Never ⏰ | []
text |

670 B

|

None

|

0 👍

/

0 👎

  static void Main(string[] args)
        {
             int[] myArray = new int[] {2, 4, 8, 16, 32, 64, 128, 256};
             Console.WriteLine(GetMaxAndMin(myArray));
            Console.ReadLine();
        }
         static string GetMaxAndMin(int[] array)
        {
             int min = array[0];
            int max = array[0];
             foreach (int n in array)
            {
                if (min > n) {
                    min = n;
                }
                 if (max < n)
                {
                    max = n;
                }
             }
             return "Min = " + min + ", Max = " + max + ".";
        }
    }

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎