Lottery quick pick program

I have been trying to get this program to work for a while now and I cant figure out why on line 22 the error is 'too few arguments in function call'.
Also in line 34 the error is also 'too few arguments in function call'.
I've been trying to make this work for hours but I can't seem to get it.

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
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include "qpick.h"

using namespace std;

int getDraws(int drawNum);
void swap(int &a, int &b);


int main()
{
	int ticket[MAX_ROWS][NUM_NUMS];
	unsigned seed = time(0);
	int numDraws;
	long long int ticketNum;

	srand(seed);

	numDraws = getDraws();
	if (numDraws == 0);
	{
		cout << "\tCanceling Transation\n\n";
			return 0;
	}

	ticketNum = seed * 10 + numDraws;
	
	for (int i = 0; i < numDraws; i++)
	{
		quickPick(ticket[i]);
		sortRow(ticket[i][]);
	}

	displayTicket(ticket, ticketNum);
}

//---------------------------------------------------------------------

int getDraws(int drawNum)
{
	int drawNum;

	cout << "Enter number of draws: ";
	cin >> drawNum;

	while (drawNum >= 5 || drawNum <= 1)
	{
		cout << "\n\tNumber of draws must be from 1 to 5 "
			 << "\n\tEnter number of draws: ";
		cin  >> drawNum;

	}



	return drawNum;
}

//------------------------------------------------------------------------

void quickPick(int row[NUM_NUMS])
{
	bool used[MAX_VAL + 1];
	int pick;

	//Reset the used array

	for ( int i = 1; i <= MAX_VAL; i++ )
		used[i] = false;

	//Pick the numbers

	for( int i=0; i<NUM_NUMS; i++ )
	{
		do
			pick = rand() % MAX_VAL + 1;
		while (used[pick]);

		row[i] = pick;
		used[pick] = true;
	}
}

//---------------------------------------------------------------------

void displayTicket(int ticket[MAX_ROWS][NUM_NUMS], long long ticketNum)
{
	int rows = ticketNum % 10;

	cout << "\n\n\n\n\n"
		<< "\n\tLOTTERY TICKET"
		<< "\n\t------------------------";
		

	for (int i = 0; i < rows; i++)

		for (int j = 0; j < NUM_NUMS; j++)

			cout << setw(5) << ticket[i][j];

	cout << "|n\t-----------------------";

}

//---------------------------------------------------------------------

void sortRow(int row[NUM_NUMS], int NUM_NUMS)
{
	int minIndex, minValue;

	for (int start = 0; start < (NUM_NUMS - 1); start++)
	{
		int minIndex, minValue;

		for (int start = 0; start < (NUM_NUMS - 1); start++)
		{
			minIndex = start;
			minValue = row[start];
			for (int index = start + 1; index < NUM_NUMS; index++)
			{
				if (row[index] < minValue)
				{
					minValue = row[index];
					minIndex = index;
				}
			}
			swap(row[minIndex], row[start]);

		}
	}
}

//---------------------------------------------------------------------

void swap(int & a, int & b)
{

		int temp = a;
		a = b;
		b = temp;

}
Last edited on
closed account (E0p9LyTq)
getDraws function declaration:
int getDraws(int drawNum);
(An int is passed into the function)

How you use it (line 22):
numDraws = getDraws();
(Not passing an int variable into the function)

sortRows function declaration:
void sortRow(int row[NUM_NUMS], int NUM_NUMS)
(A single dimension array and an int are passed into the function)

How you use it (line 34):
sortRow(ticket[i][]);
(You pass a 2 dimensional array, no int, into the function)
I got it to run, it says ticketNum is being used with out being initialized
So i got the code to run but now when I enter a number between 1-5 it gives me the "canceling Transaction" msg in line 25

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
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include "qpick.h"

using namespace std;

int getDraws(int drawNum);
void swap(int &a, int &b);


int main()
{
	int ticket[MAX_ROWS][NUM_NUMS];
	unsigned seed = time(0);
	int numDraws;
	long long int ticketNum = 0;
	int drawNum;

	srand(seed);

	numDraws = getDraws(drawNum);
	if (numDraws == 0);
	{
		cout << "\tCanceling Transation.\n\n";
			return 0;
	}

	ticketNum = seed * 10 + numDraws;
	
	for (int i = 0; i < numDraws; i++)
	{
		quickPick(ticket[i]);
		sortRow( ticket[i] );
	}

	displayTicket(ticket, ticketNum);
}

//---------------------------------------------------------------------

int getDraws(int drawNum)
{


	cout << "\n\tEnter number of draws: ";
	cin >> drawNum;

	while (drawNum < 1 || drawNum > 5)
	{
		cout << "\n\tNumber of draws must be from 1 to 5 "
			 << "\n\tEnter number of draws: ";
		cin  >> drawNum;

	}



	return drawNum;
}

//------------------------------------------------------------------------

void quickPick(int row[NUM_NUMS])
{
	bool used[MAX_VAL + 1];
	int pick;

	//Reset the used array

	for ( int i = 1; i <= MAX_VAL; i++ )
		used[i] = false;

	//Pick the numbers

	for( int i=0; i<NUM_NUMS; i++ )
	{
		do
			pick = rand() % MAX_VAL + 1;
		while (used[pick]);

		row[i] = pick;
		used[pick] = true;
	}
}

//---------------------------------------------------------------------

void displayTicket(int ticket[MAX_ROWS][NUM_NUMS], long long ticketNum)
{
	int rows = ticketNum % 10;

	cout << "\n\n\n\n\n"
		<< "\n\tLOTTERY TICKET"
		<< "\n\t------------------------";
		

	for (int i = 0; i < rows; i++)

		for (int j = 0; j < NUM_NUMS; j++)

			cout << setw(5) << ticket[i][j];

	cout << "|n\t-----------------------";

}

//---------------------------------------------------------------------

void sortRow(int row[NUM_NUMS])
{


	for (int start = 0; start < (NUM_NUMS - 1); start++)
	{
		int minIndex, minValue;

		for (int start = 0; start < (NUM_NUMS - 1); start++)
		{
			minIndex = start;
			minValue = row[start];
			for (int index = start + 1; index < NUM_NUMS; index++)
			{
				if (row[index] < minValue)
				{
					minValue = row[index];
					minIndex = index;
				}
			}
			swap(row[minIndex], row[start]);

		}
	}
}

//---------------------------------------------------------------------

void swap(int & a, int & b)
{

		int temp = a;
		a = b;
		b = temp;

}

Topic archived. No new replies allowed.