运行成功输出错误

来源:6-8 最终项目

IT通行证

2019-05-04 13:49

 string [,]nScore=new string[,]
            {
                {"景珍","90"},{"林惠洋","65"},
                {"成蓉","88"},{"洪南昌","70"},
                {"龙玉民","46"},{"单江开","81"},
                {"田武山","100"},{"王三明","68"}
            };
            int sum = 0;
            int avg = 0;
            string name = nScore[0, 0];
            int i = 0;
            string[] tName = new string[] { };
            
            for (i = 0; i < Convert.ToInt32(nScore.GetLength(0)); i++)
            {
                sum = sum + Convert.ToInt32(nScore[i, 1]);
                
               
            }
            avg = sum / Convert.ToInt32(nScore.GetLength(0));
            Console.WriteLine("平均分是{0},高于平均分的有:", avg);
            for (i = 0; i < Convert.ToInt32(nScore.GetLength(0)); i++)
            {
                
                if (Convert.ToInt32(nScore[i, 1]) > avg)
                {
                    name = nScore[i, 0];
                    Console.Write(name+" ");
                   
                }

            }

写回答 关注

1回答

  • IT通行证
    2019-05-04 13:54:42

    "平均分是{0},高于平均分的有:", avg);

    双引号中的逗号和冒号改成中文的就能通过了Console.WriteLine("平均分是{0},高于平均分的有:", avg);

    IT通行证

    正解 赞赞赞

    2019-05-04 14:01:36

    共 1 条回复 >

C#开发轻松入门

本门课程是C#语言的入门教程,将带你轻松入门.NET开发

254118 学习 · 1459 问题

查看课程

相似问题