12345
using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? int avg;
? ? ? ? ? ? int sum = 0;
? ? ? ? ? ? string[] name = new string[] { "景珍", "林慧洋", "成蓉", "洪南昌", "龍玉民", "單江開", "田武山", "王三明" };
? ? ? ? ? ? int[] score = { 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("平均分是" + avg + ",高于平均分的有:");
? ? ? ? ? ? for (int i = 0; i < score.Length; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? if (score[i] > avg)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? Console.Write(name[i] + " ");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
2020-05-10
using System;
using System.Collections.Generic;
using System.Text;
namespace projAboveAvg
{
??? class Program
??? {
??????? static void Main(string[] args)
??????? {
??????????? string[,] name = new string[,] { { "景珍", "90" }, { "林慧洋", "65" }, { "成蓉", "88" }, { "洪南昌", "70" }, { "龍玉民", "46" }, { "單江開", "81" }, { "田武山", "100" }, { "王三明", "68" } };
??????????? int avg,sum=0;
??????????? for (int i = 0; i < name.GetLength(0); i++)
??????????? {
??????????????? sum += int.Parse(name[i, 1]);
??????????? }
??????????? avg = sum / name.GetLength(0);
??????????? Console.WriteLine("平均分是{0},高于平均分的有:", avg);
??????????? for (int i = 0; i < name.GetLength(0); i++)
??????????? {
??????????????? if (avg < int.Parse(name[i, 1]))
??????????????????? Console.Write(name[i, 0] + " ");
??????????? }
??????????? Console.ReadKey();
??????? }
??? }
}