The goal of this lab is to write a program that will take list of integers
and put it into random order. The program uses a class called Randvec
(randomizable vector).
Warmup: First recall that before you can generate random numbers, you must seed the random generator with a function call such as
srand(time(0));This requires that you include
cstdlib
and ctime
.
After you have seeded the random number generator, then call
the function rand()
which returns a pseudo-random number between 0 and RAND_MAX
. How
do you get a random number between 0 and 40 (called scaling)?
How do you get a random number between 30 and 50 (called shifting and scaling)?
Below you're given a header file for this class, a source file that contains most of the implementation of the class, and a test program that uses the class.
randvec.h
randvec.cpp
testrandvec.cpp
Copy these files to a cygwin directory for lab 6. Write the code for the missing function that randomizes the lists, and create a makefile to compile and link the program. When you're done, turn in a printout of the output of the program, a printout of the makefile, and a printout of the source file for the Randvec class.