The OP simply hasn't given the full details of the problem. |
Here are the full details:
The Game:
You will start the game with an n value (default 45) for the number of cards. Divide the cards
into a random number of piles.
Playing the game (Assuming n = 45):
Each round, take one card from each pile and create a new pile. Repeat the process until you
have 9 piles of sizes 1, 2, 3, 4, 5, 6, 7, 8, and 9.
For example, if you start with 4 piles of 20, 15, 6, and 4, they would be transformed into
19, 14, 5, 3, and 4, etc.
Simulator:
The C++ program simulates the game. Your program must obtain the number of cards
(n) from the command line (see below). Assume the number of cards will never exceed 500. If
the number is not provided, then use 45 as the default value of n. If the user, enters more
than one value, print an error message and quit the program (return 0).
Start by producing a random number of piles. Make sure the total is n. Apply the steps
outlined above repeatedly until the final configuration is reached. At each step, print the
number of cards in each of the piles. The final configuration is reached when the number of
cards in the piles are in sequence: 1, 2, 3, 4, 5, 6, 7, etc. Display the number of
steps it took to reach the final configuration.
Functions:
Write a function (isTriangular) that returns true if a number n is a triangular
number, false otherwise.
Write a function to print all the elements of the array
Write a function that checks if the game is done by confirming the last sequence. You
may want to sort the values to make it easier to check. <--- This is the main problem
Thanks lastchance for the alternative function
Something worth noting:
What I've mentioned above the three (isTriangular) (printArray) (sequenceCheck) have to be functions
Also I just started to learn about vectors and arrays so my knowledge is limited