Question: In C++: A Game structure contains two fields: name, a string, and // players name points , an int. // points scored, within the range
In C++:
A Game structure contains two fields:
- name, a string, and // players name
- points, an int. // points scored, within the range 0 to 25, inclusive
An array of Game structures contains data about players and their points scored and it is sorted in ascending order by the players name. Any player can be represented any number of times in this array. Write the definition of a function named showAverages that displays each player once, followed by the average score. The average calculation will include only the non-zero values. The function takes a sorted array and returns the number of names displayed. The last element in the array is a sentinel element: the name is an empty string, and points = 999. This element has been added to enable the array processing, since the size of the array is not known. Here is an example:
Sorted Array: Output: {"Bob Doe", 23} Bob Doe: 21.5 {"Bob Doe", 0} John Smith: 14.0 {"Bob Doe", 20} // returns 2 {"Dan Jo", 0} {"John Smith", 18} {"John Smith", 10} {"", 999} Game list[100]; // assume the array has data int count; count = showAverages(list); Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
