qq_慕村2341205
2020-11-26 18:29
using System;
using System.Collections.Generic;
using System.Text;
namespace projAboveAvg
{
class Program
{
static void Main(string[] args)
{
int sum = 0,avg;
string[] name = new string[] { "景珍", "林慧祥", "成蓉", "红南昌", "龙玉民", "单江开", "田武山", "王三明" };
int[] score = new int[] { 90, 65, 88, 70, 46, 81, 100, 68 };
for (int i = 0; i < score.Length; i++)
{
sum += score[i];
}
avg = sum / score.Length;
Console.Write("平均分是{0}, 高于平均分的有:", avg);
Console.WriteLine();
for (int i = 0; i < score.Length; i++)
{
if (avg<score[i])
{
Console.Write(name[i]+" ");
}
}
}
}
}
Console.WriteLine();是多余的,把第一个Console.Write()换成Console.WriteLine()就行了
C#开发轻松入门
254118 学习 · 1459 问题
相似问题