qq_34418970 于 2016.03.31 12:06 提问

int[,] score=new int[6,3];
double[] sum=new double[3];;double[] avg=new double[3];
Console.WriteLine("请输入成绩");
Console.WriteLine("语文 数学 英语");
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 3; j++)
{
score[i, j] = Convert.ToInt32(s);
sum[j] += score[i, j];
}
Console.WriteLine("平均分是" + avg);
for (int k = 0; k < 3; k++)
{
avg[k] = sum[k]/6;
Console.WriteLine(avg[k]);
}

2个回答

lx624909677      2016.03.31 13:07
`````` static void Main(string[] args)
{
//声明一个二维数组  两行三列
int[,] myIntArray1;
myIntArray1 = new int[2, 3];
myIntArray1[0, 0] = 1;
myIntArray1[0, 1] = 11;
myIntArray1[0, 2] = 111;
myIntArray1[1, 0] = 2;
myIntArray1[1, 1] = 22;
myIntArray1[1, 2] = 222;
Console.WriteLine("{0},{1},{2}", myIntArray1[0, 0], myIntArray1[0, 1], myIntArray1[0, 2]);
Console.WriteLine("{0},{1},{2}", myIntArray1[1, 0], myIntArray1[1, 1], myIntArray1[1, 2]);
}
``````
herozhangbz   2016.03.31 13:36

``````            int[,] score=new int[6,3];
double[] sum=new double[3];
double[] avg=new double[3];
Console.WriteLine("请输入成绩");
for (int i = 0; i < 6; i++)//外循环为学生个数
{
Console.WriteLine("第{0}个学生的语文、数学、英语依次是：",i+1);
for (int j = 0; j < 3; j++)//内循环为科目成绩
{
score[i, j] = Convert.ToInt32(s);
sum[j] += score[i, j];//单科成绩总和
}
}
Console.WriteLine("每科的平均分依次是：");
for (int k = 0; k < 3; k++)
{
avg[k] = sum[k]/6;
Console.Write(avg[k]+"\t");
}