标签:tle else int line 输出矩阵 list write avg lis
1、三名参赛者,10名考官,每个参赛者的成绩是10名考官给出的成绩去掉最高分和去掉最低分而求出的平均分,输出每名参赛者最后得分。
int[,] list = new int[3, 10];
for (int i = 0; i < list.GetLength(0); i++)
{
int sum = 0, max = 0, min = 0;
float avg = 0;
for (int j = 0; j < list.GetLength(1); j++)
{
Console.WriteLine("请输入第{0}名选手中第{1}位评委的成绩:", i + 1, j + 1);
int request = int.Parse(Console.ReadLine());
sum = sum + request;
if (request > max)
max = request;
if (request < min)
min = request;
}
avg = (sum - min - max) / 8;
Console.WriteLine("第{0}名学生的成绩为:{1}", i + 1, avg);
}
Console.ReadLine();
2、 使用二维数组,存储一个矩阵,转置矩阵,输出矩阵
static void Main(string[] args)
{
int[,] a = new int[2, 3] { { 1, 2, 3, }, { 4, 5, 6 } };
int[,] b = new int[,] { };
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3; j++)
{
b[i, j] = a[j, i];
}
}
for (int i = 0; i < 3; i++)
{
Console.WriteLine(a[i,1]);
}
Console.Read();
}
3、 统计5*6数组中奇数和偶数的个数
标签:tle else int line 输出矩阵 list write avg lis
原文地址:https://www.cnblogs.com/deepsleepinger/p/9721281.html