This code will be in C++ and will have 3 files. This lab will test your ability to use a custom stack class and a custom queue class. It will also test your ability to use a standard algorithm from STL. ReOrder ReOrder() takes three arguments as shown in Reorder.cpp. Complete this function using stack and queue. The number 0 is used as a delimiter between sets of numbers. The new array should have all negative numbers on one side and all positive numbers on the other side. The zero should be pushed to the end of the array. See the sample run below. Custom Compare Function The custom compare function is used in conjunction with the standard sort function. The numbers to be sorted are of a standard data type but create this custom compare function anyway. The function should result in a sorted array from the greatest number to the least number. Sample Run A sample run is as follows: array: -3 2 -1 5 1 -4 0 11 12 13 -11 -12 0 -1 -2 6 8 7 newArray: -3 -1 -4 1 5 2 -11 -12 13 12 11 -1 -2 7 8 6 0 0 newArray sorted: 13 12 11 8 7 6 5 2 1 0 0 -1 -1 -2 -3 -4 -11 -12 Be sure to document your code with the file name, your name and student number. Add comments throughout the code where necessary.
This code will be in C++ and will have 3 files.
This lab will test your ability to use a custom stack class and a custom queue class. It will also test your ability to use a standard
ReOrder
ReOrder() takes three arguments as shown in Reorder.cpp. Complete this function using stack and queue. The number 0 is used as a delimiter between sets of numbers. The new array should have all negative numbers on one side and all positive numbers on the other side. The zero should be pushed to the end of the array. See the sample run below.
Custom Compare Function
The custom compare function is used in conjunction with the standard sort function. The numbers to be sorted are of a standard data type but create this custom compare function anyway. The function should result in a sorted array from the greatest number to the least number.
Sample Run
A sample run is as follows:
array: -3 2 -1 5 1 -4 0 11 12 13 -11 -12 0 -1 -2 6 8 7
newArray: -3 -1 -4 1 5 2 -11 -12 13 12 11 -1 -2 7 8 6 0 0
newArray sorted: 13 12 11 8 7 6 5 2 1 0 0 -1 -1 -2 -3 -4 -11 -12
Be sure to document your code with the file name, your name and student number. Add comments throughout the code where necessary.
Step by step
Solved in 4 steps with 1 images