using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace shuzujichu
{
class Program
{
static void Main(string[] args)
{
//在数组中产生一批随机数,记录其中最大数,以及最大数的位置
const int N = 10;
int[] a = new int[N];
int max, max_i;
Random random = new Random();
for (int i = 0; i < N; i++)
{
a[i] = random.Next(10, 99);
}
max = a[0];
max_i = 0;
for (int i = 0; i < N; i++)
{
if (max < a[i])
{
max = a[i];
max_i = i;
}
}
for (int i = 0;i < N;i++)
{
Console.Write("{0} ",a[i]);
}
Console.WriteLine();
Console.Write("max:{0},location:{1}",max,max_i);
Console.ReadKey();
}
}
}
效果如图: