随机产生5个1-100的数,求其中的最大值。
2018-11-29 本文已影响0人
唯一的one


Random random = new Random();
int[] a = new int[5];
int max = 0;
for (int i = 0; i < a.Length; i++)
{
a[i] = random.Next(1, 100);
Console.WriteLine(a[i]);
if (max < a[i])
{
max = a[i];
}
}
Console.WriteLine("最大值是" + max);