Reputation: 43
beginner to c++ , i have two arrays. 1 is String, the other is 2D array (int). How do I assign the artists to the scores??
int Artistlist()
{
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}
};
}
Upvotes: 0
Views: 117
Reputation: 220
dude if the arrays are ordered correctly i think you should use
Artist[artistnum]
Scores[artistnum][0]
.
.
.
Scores[artistnum][9]
as John said.
Upvotes: 0
Reputation: 121
You could use a std::map and a std::vector.
std::map<std::string, std::vector<int>> map;
std::vector<int> DegasScores;
DegasScores.push_back(5);
DegasScores.push_back(5);
DegasScores.push_back(6);
DegasScores.push_back(8);
DegasScores.push_back(4);
DegasScores.push_back(6);
DegasScores.push_back(8);
DegasScores.push_back(8);
DegasScores.push_back(10);
map["Degas"] = DegasScores;
Upvotes: 1