Question: Exercise Objectives Sorting arrays ( bubble sort only ) Defining 2 D arrays Initialize 2 D arrays ( initializer list and using loops ) and
Exercise Objectives
Sorting arrays bubble sort only
Defining D arrays
Initialize D arrays initializer list and using loops and printing arrays
Problem Description
Write a program that allows the user to enter weights for players in different teams, store their weights in a array, and then sort the weights using the bubble sort algorithm.
Define a function called ReadWeights that prompts the user to enter the weights for the players and stores them in a D array called weights with a size of where is the number of teams and is the number of players in each team.
Define a function called printWeights that prints the weights stored in the weights array
Define a function called Sort that sorts the weights stored in the weights array in ascending order using the bubble sort algorithm.
In the main:
Call ReadWeights to prompt the user to enter the weights of players and store them in the weights array.
Call printWeights to print the weights before sorting
Call Sort to sort the weights in descending order.
Call printWeights to print the weights after sorting.
Sample Output:
Enter the number of teams:
Enter the number of players in each team:
Enter weights for players in team :
Enter weights for players in team :
Enter weights for players in team :
The weights of players:
In team :
In team :
In team :
The weights of players in ascending order:
In team :
In team :
In team :
Hint: you can use the bubble sort code:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
