+----------------------+ | Hello from CISC 3142 | +----------------------+
Here is a simple example … the Collatz sequence for the number 3 is:
3, 10, 5, 16, 8, 4, 2, 1What is especially interesting is that it appears as if the sequence will keep bouncing around, but invariably, they end up at 1.
The Collatz Conjecture (one of the more famous unsolved math questions) states that every Collatz sequence eventually transforms to 1.
Write a C++ program to prompt for a start value and end value, and print the collatz sequences of the integers in the specified range (inclusive)
Sample Test Run #1
from: 10 to: 20 10, 5, 16, 8, 4, 2, 1 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 12, 6, 3, 10, 5, 16, 8, 4, 2, 1 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 15, 46, 23, 70, 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1 16, 8, 4, 2, 1 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 18, 9, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 19, 58, 29, 88, 44, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 20, 10, 5, 16, 8, 4, 2, 1
names.data
results.data, each name / id pair on a separate line
load, sort, writeToFile functions
swap function for use by the sort?
Sample Test Run #1
For example if the file names.data contains:
Langsam Tenenbaum Arnow Weiss Coxupon program termination, the console output should be:
5 records processed.the file
results.data should contain:
Arnow 1003 Cox 1005 Langsam 1001 Tenenbaum 1002 Weiss 1004and the exit code should be 0.
Sample Test Run #2
If the file names.data did not exist, the console output should be:
*** Exception *** input file names.data not foundand the exit code should be 1.
Sample Test Run #3
If the file names.data contains more than 50 names, the console output should be:
*** Exception *** array capacity exceededand the exit code should be 1.