來啦來啦交作業(yè)!
using System;
using System.Collections.Generic;
using System.Text;
namespace projAboveAvg
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? int avg = 0;
? ? ? ? ? ? int sum = 0;
? ? ? ? ? ? int[] scores=new int[8]{90,65,88,70,46,81,100,68};
? ? ? ? ? ? string[] names= new string[8]{"景珍","林惠祥","成蓉","洪南昌","龍玉民","單江開","田武山","王三明"};
? ? ? ? ? ? foreach(int x in scores){
? ? ? ? ? ? ? ? sum+=x;
? ? ? ? ? ? }
? ? ? ? ? ? avg=sum/(names.Length);
? ? ? ? ? ? Console.Write("平均分是{0},高于平均分的有:",avg);
? ? ? ? ? ? for(int i=0;i<scores.Length;i++){
? ? ? ? ? ? ? ? if(scores[i]>avg){
? ? ? ? ? ? ? ? ? ? Console.Write(names[i]);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ??
? ? ? ? ? ??
? ? ? ? }
? ? }
}
2024-02-27
Console.Write("平均分是{0},高于平均分的有:",avg)? Writer后要加Line,進行換行,輸出格式才能與標準答案一致!