Question:Input a array A with N numbers,where N>1 and N could be very large(more than 1000)
Then search the largest and smallest item in the array.
The following is what I did for searching the largest and smallest item in the array:
public static void CompareArrayElement(int [] array, int n)
{
int MaxValue=array[0];
int MinValue=array[0];
for(int index=0;index<n-1;index++)
{
if(array[index]<MinValue)
array[index]=MinValue;
// return MinValue;
else
if(array[index]>MaxValue)
array[index]=MaxValue;
// return MaxValue;
else continue;
}
Console.WriteLine("MaxValue="+MaxValue);
Console.WriteLine("MinValue="+MinValue);
}
My problem is how to input so large number of items in the array.Due to the huge number,I cannot fill the array manually.
我朋友告诉我说用参数传递,请问该怎么做?
谢谢.