
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 1.71 KB | hits: 11 | expires: Never
How can my random number generator come up from lowest to highest in C ? [closed]
/*This app will give you your lotto max numbers!*/
#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;
int main()
{
int lotto[7];
//allows users to input a seed, that way the tickets wont be
//generated the same if they want two.
unsigned seed;
cout << "Enter seed ";
cin >> seed;
srand( seed ) ;
//greeting
cout << "*** LOTTO MAX INSTA PICK ***" << endl;
cout << " " << endl << endl;
cout << "Your Insta Pick Numbers" << endl;
cout<< " " << endl << endl;
//initilizes the counter and making sure the amount of numbers does not exceed 21
for (int counter = 1; counter <= 7;++ counter)
{
//outputs numbers between 1 and 27 with 7 numbers in each row
cout << setw(1) << (1 + rand() % 49) << " " ;
//stops the counter for each row
if (counter % 7 == 0)
cout << endl;
}
//space in between the numbers and tag numbers
cout<< " " << endl << endl;
cout << "Your Tag Numbers" << endl;
cout << " " << endl << endl;
//initilizes counter and makes sure numbers dont go over 6
for (int counter = 1; counter <= 6; ++ counter)
{
//sets the numbers between 0 and 9 and outputs them
cout << setw(0) << (0 + rand() % 9)<< " " ;
//stops the counter
if (counter % 9 == 0)
cout << endl;
}
cout << " " << endl << endl;
//end message
cout << "Thank you for playing!! please check ticketn a year minus a day from date of purchase" <<endl;
};
std::set<int> numbers;
while(numbers.size() < 7)
{
numbers.insert((rand() % 49) + 1);
}