首页 新闻 搜索 专区 学院

如何将下面的程序做一下修改,使之运行正确。

0
[已解决问题] 解决于 2012-06-06 23:18

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();

        }
    }
}

foxing的主页 foxing | 初学一级 | 园豆:5
提问于:2012-06-06 19:51
< >
分享
最佳答案
0

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();
}
奖励园豆:5
artwl | 专家六级 |园豆:16526 | 2012-06-06 22:06

very good

foxing | 园豆:5 (初学一级) | 2012-06-06 23:17
其他回答(1)
0

分都没得啊

凡的世界 | 园豆:204 (菜鸟二级) | 2012-06-06 20:49

什么分没得?

支持(0) 反对(0) foxing | 园豆:5 (初学一级) | 2012-06-06 21:20
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册