2D 配列 (列) から平均を生成できます。私は理解できませんが、その平均をどのようにソートするか。新しい配列 ( rankedscore[]
) を作成する必要があります。
どんな助けでも大歓迎です:
int rankedArtist() // ranked artist based on score
{
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\tRanking by Artist"<< endl;
cout << "\t===========================================" << endl;
int total = 0;
float faverage;
double AverageScore[5];
double average;
double rankedscore[A2_ROWSIZE];
for (int x=0; x<5; x++)
{
cout << "\n\t" << Artist[x] << "\t\t";
for (int col = 0; col < A2_COLSIZE; col++)
{
total+=Scores[x][col];
}
faverage = (float)total / 10.0f;
average = total = 0;
AverageScore[x] = faverage;
}
}