我正在尝试查找每列的平均值(即 {5,5,6,8,4,6,8,8,8,10} 并打印每一行:。以下是代码。我继续获得 0打印,我确定某处有问题。任何帮助都会很棒。谢谢。
int ScoreAverage() // average of artist scores
{
const int A1_SIZE = 5, A2_ROWSIZE =5, A2_COLSIZE =10;
string Artist[A1_SIZE]={ "Degas", "Holbien", "Monet", "Matisse", "Valesquez" };
int Scores[A2_ROWSIZE][A2_COLSIZE] = {{5,5,6,8,4,6,8,8,8,10},{8,8,8,8,8,8,8,8,8,8},
{10,10,10,10,10,10,10,10,10,10},{5,0,0,0,0,0,0,0,0,0},{5,6,8,10,4,0,0,0,0,0}};
cout << "\n\n\t-------------------------------------------" << endl;
cout << "\t\tAverage Scores by Artist"<< endl;
cout << "\t===========================================" << endl;
int total = 0;
double average, faverage;
for (int x=0; x<5; x++)
{
cout << "\n\t" << Artist[x] << "\t\t";
for (int col = 0; col < 5; col++)
{
for (int row = 0; row < 10; row++)
{
total+=Scores[row][col];
}
average = total/10;
average = faverage;
}
average = total = 0;
cout << "\tAverage ... " << faverage << endl;
}
}