Find minimum and maximum number from array, minimum is always 0

后端 未结 5 1667
春和景丽
春和景丽 2021-01-12 06:26

The program first asks the user for the number of elements to be stored in the array, then asks for the numbers.

This is my code

    static void Main         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-12 06:36

    This code will help you in very simple way without adding any loops and conditions

    int[] arr={1,1,2,4,5,1,2,1};
    Array.Sort(arr);
    Console.WriteLine("Min no: "+arr[0]);
    Console.WriteLine("Max no: "+arr[arr.Length-1]);
    

提交回复
热议问题