Project Random Number Gen to be

Hey,

I'm a newbie here and came here cause I'm stuck on how to approach something. Here's the info, I'm working on a project to prove that the lottery can't be predicted. The goal is to create a Random Number Generator that will compare it's results with a list of already winning results.

THe system creates a random numbers, num1,num2,num3,num4,num5 and a extra numX
Then it compares with the first numbers in the file with al the winning numbers.
If it's the same it creates another that will be compared to the next winning number.
If it's the same, it continues
if not, it restarts

this goes on until it has completed the hole list of winning numbers.
Then I want it to generate the next random numbers. If my half minded friend at work says, it would be the winning number. I bet him 100$ and it's ON!
So I'm building this project to prove that little turd wrong. lol

SO if someone can help
Right now I have duplicated what this guy did on YouTube

https://www.youtube.com/watch?v=OWb70pgjnKM

It works and now I'm searching for that reading into file and comparing with the winning numbers file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <iomanip>
#include <fstream>
#include <stdlib.h>
#include <time.h>
#include <sstream>
#include <string>
#include <stdio.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

using namespace std;

int main()
{
	srand(time(0));
	
	int balls[56];
	int megaBall[46];
	int ballsOut[5];
	int i,j,k;
	int numberOfSets;
	int megaBallOut;
	
	
	cout <<"How many sets of numbers would you like to generate?" << endl;
	cin >> numberOfSets; 
	cout << endl;
	cout <<"Here are your numbers:"	<< endl << endl;
	
	for ( k=0; k<numberOfSets; k++)
	{
		for(i=0; i<49;i++) balls[i]=i+1;
		for(j=0; j<7;j++) megaBall[j]=j+1;
		
		random_shuffle(&balls[0],&balls[49]);
		random_shuffle(&megaBall[0], &megaBall[7]);
		
		for(i=0; i<5; ++i) ballsOut[i] = balls[i];
		
		megaBallOut = megaBall[i];
		
		sort(ballsOut, ballsOut + sizeof(ballsOut)/sizeof(ballsOut[0]));
		
		for(i=0; i<5; ++i) cout<<setw(5) << ballsOut[i] <<"";
		cout<<setw(6) << megaBallOut << endl;
	}
	
	
	return 0;
} 
The likely hood that sequential matches occur increase by a insane amount each time you hit another match, maybe taking years but it should be fun for you to program just the same.

Start with this
http://www.cplusplus.com/doc/tutorial/files/

Try something and let us know when if you get stuck.
Last edited on
Registered users can post here. Sign in or register to post.