Can some one tell me what's wrong with my code? I am generating tickets and would like to compare each ticket number to the wining numbers and then display the results of how many wins ( 1 number matching, two matching etc) but my code doesn't do that.
and so on for each number,do I need to put if else after the first if and also if someone can help me set my loop to check each ticket number that would be great, I set the loop for the ticktets but I realized that it should loop based on each number on the ticket but I don't know how to go about. Thanks.
#include <iostream>
#include <vector>
#include <ctime>
usingnamespace std;
int main (void) {
vector <unsigned> Numbs;
srand ( time (NULL) ); // Seed random number generator
// Select five winning numbers in draw.
for (int x = 0; x < 5; x++) {
unsigned Value;
Another:
Value = rand () % 47 + 1; // Pick a winning number
/* Determine if there is a duplicate with those already selected */
for ( auto V : Numbs )
/* This is probably not required, but could happen */
if ( V == Value )
goto Another;
Numbs.push_back (Value); // Save new value in array.
cout << "[" << Value << "] "; // Display to prove algo works.
}
return 0;
}