c++ lotto program

Hello. i wrote a program that will compare the past several years of winning pick 3 numbers to the numbers that are in the 13 tier.

what i want to add now to the program. is a function that will tell me what tier has the most hits.

Below is the code:

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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// theisonewscpp.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string> 
#include <algorithm>


using namespace std;

bool myfunction (int i,int j) { return (i<j); }

std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
	stringstream ss(s);
	std::string item;
	while(std::getline(ss, item, delim)) {
		elems.push_back(item);
	}
	return elems;
}


std::vector<std::string> split(const std::string &s, char delim) {
	std::vector<std::string> elems;
	return split(s, delim, elems);
}


int main()

{
	// Arrays that will be copyed into vectors below.
	int one[]={409 , 508 , 509, 607, 608 ,707 , 139 , 148 , 149 , 157 , 158 ,166 , 167 ,229 , 238 , 239 ,247 , 248 ,256 ,257 ,266 ,337 ,338 ,346 ,347 , 355 , 356 , 445 , 446 ,455};
	int two[]={309 , 408 , 507 , 606 , 609 ,708 ,129 ,138 , 147 , 156 , 159 ,168 ,177 , 228 , 237 , 246 , 249 , 255 , 258 , 267 , 336 , 339 , 345 , 348 , 357 , 366 , 444 , 447 , 456 , 555};
	int three[]={209,308,407,506,709,808,119,128,137,146,155,169,178,227,236,245,259,268,277,335,344,349,358,367,448,457,466,556};
	int four[]={208,307,406,505,809,118,127,136,145,179,188,226,235,244,269,278,334,359,368,377,449,458,467,557,566};
	int five[]={900,108,207,306,405,909,117,126,135,144,189,225,234,279,288,333,369,378,459,468,477,558,567,666};
	int six[]={800,107,206,305,404,116,125,134,199,224,233,289,379,388,469,478,559,568,577,667};
	int seven[]={700,106,205,304,115,124,133,223,299,389,479,488,569,578,668,677};
	int eight[]={600,105,204,303,114,123,222,399,489,579,588,669,678,777};
	int nine[]={500,104,203,113,122,499,589,679,688,778};
	int ten[]={400,103,202,112,599,689,779,788};
	int eleven[]={300,102,111,699,789,888};
	int twelve[]={200,101,799,889};
	int thirteen[]={100,899,999};

	// array that will be compared from
	int previous_pick_3_numbers[20]={346,794,861,529,347,925,196,969,243,837,740,025,822,809,454,843,942,510,573,346};
	char* tier[13] = {"one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen"};

	vector<int> pick3(previous_pick_3_numbers,previous_pick_3_numbers+20);

	vector<int> firsts_tier(one,one+30);
	vector<int> seconds_tier(two,two+30);
	vector<int> third_tier(three,three+28);
	vector<int> fourths_tier(four,four+26);
	vector<int> fifths_tier(five,five+24);
	vector<int> sixths_tier(six,six+20);
	vector<int> sevenths_tier(seven,seven+16);
	vector<int> eighths_tier(eight,eight+14);
	vector<int> ninths_tier(nine,nine+10);
	vector<int> tenths_tier(ten,ten+8);
	vector<int> elevenths_tier(eleven,eleven+6);
	vector<int> twelves_tier(twelve,twelve+4);
	vector<int> thirteenths_tier(thirteen,thirteen+4);

	vector<vector<int> > all_vector;
	all_vector.push_back(firsts_tier);
	all_vector.push_back(seconds_tier);
	all_vector.push_back(third_tier);
	all_vector.push_back(fourths_tier);
	all_vector.push_back(fifths_tier);
	all_vector.push_back(sixths_tier);
	all_vector.push_back(sevenths_tier);
	all_vector.push_back(eighths_tier);
	all_vector.push_back(ninths_tier);
	all_vector.push_back(tenths_tier);
	all_vector.push_back(elevenths_tier);
	all_vector.push_back(twelves_tier);
	all_vector.push_back(thirteenths_tier);

	vector<char*> tiers_str(tier, tier+13);

	int vnb = 13;

	char curr_pick[4];
	
	char qwe[4]; //123
	char qew[4]; //132
	char weq[4]; //231
	char wqe[4]; //213
	char eqw[4]; //312
	char ewq[4]; //321

	int iqwe; //123
	int iqew; //132
	int iweq; //231
	int iwqe; //213
	int ieqw; //312
	int iewq; //321

	ifstream myfile ("pik3numbers.txt");
	string line;

	if (myfile.is_open())
	{
		while ( myfile.good() )
		{
			getline (myfile,line);
			vector<string> splitted = split(line, ' ');
			if( splitted.size()==0)
			{
				continue;
			}
			string str = splitted[0];
			sprintf(curr_pick,"%c%c%c",str.c_str()[0],str.c_str()[2],str.c_str()[4]);

			sprintf(qwe,"%c%c%c",str.c_str()[0],str.c_str()[2],str.c_str()[4]);
			sprintf(qew,"%c%c%c",str.c_str()[0],str.c_str()[4],str.c_str()[2]);
			sprintf(weq,"%c%c%c",str.c_str()[2],str.c_str()[4],str.c_str()[0]);
			sprintf(wqe,"%c%c%c",str.c_str()[2],str.c_str()[0],str.c_str()[4]);
			sprintf(eqw,"%c%c%c",str.c_str()[4],str.c_str()[0],str.c_str()[2]);
			sprintf(ewq,"%c%c%c",str.c_str()[4],str.c_str()[2],str.c_str()[0]);

			iqwe = atoi(qwe);
			iqew = atoi(qew);
			iweq = atoi(weq);
			iwqe = atoi(wqe);
			ieqw = atoi(eqw);
			iewq = atoi(ewq);

			for(int i =0; i<all_vector.size(); ++i)
			{
				sort (all_vector[i].begin(), all_vector[i].end());
			}
			for(int i =0; i<all_vector.size(); ++i)
			{
				//vector<int> curr = all_vector[i];
				//sort (curr.begin(), curr.end());

				//cout << "\n";
				//cout << "Looking in Tier " <<  tiers_str.at(i) << "\n";

				if ( binary_search(all_vector[i].begin(), all_vector[i].end(), iqwe) ||
					binary_search(all_vector[i].begin(), all_vector[i].end(), iqew) ||
					binary_search(all_vector[i].begin(), all_vector[i].end(), iweq) ||
					binary_search(all_vector[i].begin(), all_vector[i].end(), iwqe) ||
					binary_search(all_vector[i].begin(), all_vector[i].end(), ieqw) ||
					binary_search(all_vector[i].begin(), all_vector[i].end(), iewq) )
					cout << curr_pick << " found in Tier " << tiers_str.at(i) << "!\n"; 
				//else 
					//cout << "not found.\n";

			}
		}
		myfile.close();
	}

	else cout << "Unable to open file"; 


	system("pause");
	return 0;
}


816 found in Tier two!
663 found in Tier two!
602 found in Tier six!
630 found in Tier five!
905 found in Tier one!
205 found in Tier seven!
154 found in Tier four!
453 found in Tier two!
936 found in Tier five!
203 found in Tier nine!
628 found in Tier three!
192 found in Tier two!
381 found in Tier two!
277 found in Tier three!
034 found in Tier seven!
952 found in Tier three!
743 found in Tier one!
286 found in Tier three!

Press any key to continue . . .



Details: there is 13 tiers. each tier holds several series of 3, 1 digit numbers i.e 123 346 etc. The program will read from a txt file that has the past several years of winning pick 3 lotto numbers. The program will compare the numbers in the txt file to the numbers in the tiers. it will tell me what number has been found in what tier.

now for my request. I want the program to also tell me in what tier was the most numbers found in. for example:

Tier 4 has the most Hits.



Last edited on
I don't quite understand the question. What do you mean by hits and tiers? Could you expand your explanation please.
Topic archived. No new replies allowed.