5天,还有带回家的C语言,结束啦
5天,还有带回家的C语言,结束啦
5天,还有带回家的C语言,结束啦
2020-04-09
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();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace projAboveAvg
{
class Program
{
static void Main(string[] args)
{
string[] names = new string[] { "景珍", "林惠阳", "成蓉", "洪南昌", "龙玉民", "单江开", "田武山", "王三明", };
int[] score = new int[] { 90, 65, 83, 70, 56, 81, 100, 68 };
int avg, sum = 0;
for (int i = 0; i < score.Length; i++)
{
sum += score[i];
}
avg = sum / score.Length;
Console.Write("平均分是{0},高于平均分的有:", avg);
Console.ReadKey();
int s = 76;
for (int x = 0; x < score.Length; x++)
{
if (score[x] > s)
{
Console.Write(names[x]+' ');
}
}
}
}
}
求个最佳答案,嘿嘿。
举报