using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace midtest1
{
class Program
{
static void Main(string[] args)
{
int[] grade = new int[50];
Random r = new Random();
Console.WriteLine("the 50 student's grade is:");
for (int i = 0; i < grade.Length / 10; i++)
{
for (int k = 0; k < grade.Length / 5; k++)
{
grade[i] = r.Next(1, 100);
Console.Write("{0},{1}", grade[i], "");
}
Console.WriteLine();
}
Console.WriteLine("The top grade is:{0},The bottom grade is:{1},The average is:{2}", grade.Max(), grade.Min(),
grade.Average());
Console.ReadKey();
}
}
}
for改一下:
for (int i = 0; i < grade.Length; i++) { grade[i] = r.Next(1, 100); Console.Write("{0},{1}", grade[i], ""); if ((i + 1) % 10 == 0) Console.WriteLine(); }
very good
分都没得啊
什么分没得?