//求数组最大值和最小值
using System;
class class1
{
static void Main(string[] args)
{
int i = 0;
int top;
int large, small;
int[] a = new int[50];
string s;
Console.WriteLine("输入数组元素");
while(char.Parse(s = Console.ReadLine()) != '\n') //在这则发生错误,想保留到回车结束的功能。我以前是学C不 //知道C#里行不行?
{
a[i] = int.Parse(s);
i++;
}
top = i;
large = a[0];
small = a[0];
for(i = 1; i < top; i++)
{
if(a[i] > large)
{
large = a[i];
}
if(a[i] < small)
{
small = a[i];
}
}
Console.WriteLine("Largst element in the array is {0}", large);
Console.WriteLine("Smallest element in the array is {0}", small);
Console.ReadLine();
}
}