为了账号安全,请及时绑定邮箱和手机立即绑定

记录一下学习

            var names = new string[] { "景珍", "林惠洋", "成蓉", "洪南昌", "龙玉民", "单江开", "田武山", "王三明" };
            var score = new int[] { 90, 65, 88, 70, 46, 81, 100, 68 };
            int sum = 0;
            int avg = 0;
            int index = 0;
            for (int x = 0; x < score.Length; x++)
            {
                sum += score[x];
            }
            avg = sum / score.Length;
            Console.WriteLine("平均分是" + avg + ",高于平均分的有:");
            for (int e = 0; e < score.Length; e++)
            {
                if (avg < score[e])
                {
                    index = e;
                }
                else
                {
                    continue;
                }
                Console.Write(names[index] + " ");
            }


正在回答

1 回答

//学生姓名
            string[] Name = new string[] { "景珍", "林惠洋", "成蓉", "洪南昌", "龙玉民", "单江开", "田武山", "王三明" };
            int[] Score = new int[] { 90, 65, 88, 70, 46, 81, 100, 68 };
            int Sum = 0;
            foreach(int x in Score)
            {
                Sum += x;
            }
            Sum /= Name.Length;
            Console.WriteLine("平均分是{0},高于平均分的有:",Sum);
            for (int i = 0;i<Name.Length;i++)
            {
                if (Score[i]>Sum)
                {
                    Console.Write(Name[i]+' ');
                }
            }
            Console.ReadKey();



1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

记录一下学习

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信