#include <iostream>
#include <ctime> //include the time() function as a way of seeding rand()
#include <cmath> //need this for pow()
//#include "keno.h"
using namespace std;
void generatenumber();
float money = 100; // give the player $100 and allow decimal bets
//int draw;
int main()
{
float bet;
cout << "Welcome to Keno! You have $" << money << " to bet." << endl;
while (bet != -1) // use "-1" to quit
{
int spots;
int draws[20]; //set up a 20-element array for random numbers
int comparison[80]; // set up an 80-element array to check random numbers against so we don't get repeats
int selection;
if (money < 0)
{ cout << "Sorry, you are out of money. " << endl; break; }
cout << "How much would you like to bet? ";
bool stillbetting = true;
while (stillbetting) {
cin >> bet;
if (bet > money) {
cout << "You don't have $" << bet << " to bet. Bet again." << endl;}
else (stillbetting = false);
}
money -= bet; // make sure the player doesn't play for free
cout << "How many spots would you like to select? ";
cin >> spots;
if ((spots < 5) || (spots > 10) ) { //make them select at least five spots
cout << "Please select between five and ten spots." << endl; }
int * guesses = new int[spots];
cout << "Please use numbers from 1 to 80 for your guesses."
<< endl;
for (int i = 0; i < spots; i++) // loop through the array
{
cout << "Spot " << i+1 << "? ";
int guess;
cin >> guess;
guesses[i] = guess;
}
for(int i=0; i<80; i++) comparison[i] = 0;
cout << "And the numbers are...";
int randomnumber;
srand(time(NULL));
for (int i = 0; i < 20; i++) //loop through the array
{
randomnumber = rand() % 80 + 1;
while (comparison[randomnumber-1] == 0)
{
draws[i] = randomnumber; //put the number in the array
comparison[randomnumber-1] = 1; // flip the value of comparison[randnum]
}
if (i < 19)
cout << draws[i] << ", ";
else cout << "and " << draws[i] << ". ";
}
}
return 0;
}