Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that generates 6 unique random numbers between 1 and 49 and stores the six unique random numbers in a vector. Generate sets

Write a program that generates 6 unique random numbers between 1 and 49 and stores the six unique random numbers in a vector. Generate sets of 6 unique random numbers and store each set in one vector until a set of unique random number matches the original 6 unique random numbers. Count how many times there are no matches between the original set and a generate set, how many times there is one match, etc. The program stops generating unique sets when a generated set and the original set match perfectly, that is have 6 matches. Display how many sets the program generated when the original set and a generated set matched perfectly. Display the number of times there were 0 matches, 1 match, 2 matches, etc.

Write a function, generate that returns a unique set of random numbers in a vector. The function's prototype is vector generate(int n, int lbound, int ubound);

where n is the number of random numbers, lbound is the smallest possible random number in the set and ubound is the largest possible random number.in the set.

Write a function, match, that counts the number of times a random number appears in both sets of random numbers. The function returns the number of matches. The function's prototype is

int match(const vector& set1, const vector& set2);

For example, {1,2,3,4,5,6} and {6,5,4,3,2,1} have 6 matches.

The main function may look like

vector original = generate(6, 1, 49);

vector candidate;

do

{

candidate = generate(6, 1, 49);

// statistics

} while(match(original, candidate) < original.size());

//more statistics

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions