Vectors and Searching Purpose To practice the use of a vecto

Vectors and Searching Purpose: To practice the use of a vector and the vector functions: Specifications: This program will allow the user to see a list of teams, add a team to the list, or search for a team using an ID. 1. Structure Definition (5 points) First define struct TeamS with an integer field to hold an ID, and an array of strings with three elements to hold the names of the team members. In the main function, declare an empty vector of TeamV and also the following arrays: const int ID [NUM_TEAMS] ={ 123, 321, 456, 789}; const string MEMBERS [NUM_TEAMS] [NUM_MEMBERS ] = { {\"Mike\", \"Joe\", \"John\"}, {\"Christina\", \"Kevin\", \"Jim\"}, {\"Thomas\", \"Kim\", \"Emily\"}, {\"July\", \"Jason\", \"Jason\"} }; 2. Creating the vector- Call a function with the following prototype and pass in the empty vector and the arrays: void Initialize (vector & TeamV, const int id[], const string m[][NUM_MEMBERS], int arraySize); The function should place into the vector the elements of the arrays. For example, the first element of the vector will have team id: 123 and members: Sarah, Joe, and John. The second element of the vector will have team id: 321 and members: Chris, Kevin, and James, and so on. 3. The print function (10 points) Back in main, call a function with the following prototype to show that your vector has been populated with the team information: void printList (const vector & TeamV); The function simply prints out the content of the vector.

Solution

Answer

//Definition for the struct
struct TeamS{
int team_ID;
char str_arr[20][20];
struct TeamS *next;
}

//initialization function
void Initialize(vector &TeamV, const int id[], const string m[][NUM_MEMBERS], int arraySize)

{
   TeamS *Team = TeamV;
   for(int i=0;i<NUM_TEAMS;i++)
   {
       Team->team_ID = id[i];
       for(int j=0; j<NUM_MEMBERS; j++)
       {
           Team->*str_arr[j] = *m[j];
       }  
   }
}

Vectors and Searching Purpose: To practice the use of a vector and the vector functions: Specifications: This program will allow the user to see a list of teams

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site