using System;
namespace Console20161112
{
class MainClass
{
public static void Main(string[] args) {
var studentScore = new string[8, 2] {
{"吴松","89"},
{"钱东宇","90"},
{"伏晨","98"},
{"陈陆","56"},
{"周蕊","60"},
{"林日鹏","91"},
{"何昆","93"},
{"关欣","85"}
};
var maxScoreIndex = maxFun(studentScore, studentScore.GetLength(0));
Console.WriteLine("分数最高的是{0}, 分数是{1}", studentScore[maxScoreIndex, 0], studentScore[maxScoreIndex, 1]);
}
static int maxFun(string[,] studentScore, long length) {
int index = 0;
var maxScore = Int32.Parse(studentScore[0, 1]);
for (int i = 0; i < length; i++) {
if (Int32.Parse(studentScore[i, 1]) >= maxScore) {
maxScore = Int32.Parse(studentScore[i, 1]);
index = i;
}
}
return index;
}
}
}
using System;
using System.Text;
namespace Console20161112
{
class MainClass
{
public static void Main(string[] args) {
var studentScore = new string[8, 2] {
{"景珍","90"},
{"林惠洋","65"},
{"成蓉","88"},
{"洪南昌","70"},
{"龙玉民","46"},
{"单江开","81"},
{"田武山","100"},
{"王三明","68"}
};
var average = getAverageScore(studentScore, studentScore.GetLength(0));
Console.WriteLine("平均分是{0}, 高于平均分数的有\n{1}", average, nameArr(studentScore, average));
}
static StringBuilder nameArr(string[,] studentScore, double average) {
var names = new StringBuilder("");
for (int i = 0; i < studentScore.GetLength(0); i++) {
if (Int32.Parse(studentScore[i, 1]) > average) {
names = names.Append(studentScore[i, 0]).Append(" ");
}
}
return names;
}
static double getAverageScore(string[,] studentScore, int len) {
double sum = 0;
for (int i = 0; i < len; i++) {
sum += Int32.Parse(studentScore[i, 1]);
}
return sum / len;
}
}
}