Thursday, April 19, 2012

Matching numbers

I'm trying to finish a homework assignment and I can't find this anywhere. I'm trying to match input numbers with randomly generated numbers and displaying how many of the 5 are correct(also with a win/lose message) This is what I have so far and any help would be appreciated. :)



#include <iostream>
#include <cstdlib>

using namespace std;



void main()
{
//variables
int lottery[5], user[5];
int count = 0;
int num1, num2, num3, num4, num5;
int winnum;
//generating numbers
for (int i=0; i <5; i++)
{
lottery[i] =1+rand()%9;
}
//input
cout << "Enter a digit between 0-9: ";
cin >> num1;
cout << "Enter a digit between 0-9: ";
cin >> num2;
cout << "Enter a digit between 0-9: ";
cin >> num3;
cout << "Enter a digit between 0-9: ";
cin >> num4;
cout << "Enter a digit between 0-9: ";
cin >> num5;


winnum = rand();

//for (int i=0; i<5; i++)
// cin >> user[i];

//display


cout << "Winning Lottery Numbers: " << winnum << endl;

cout << "Your ticket Numbers: " << num1 << num2 << num3 << num4 << num5 << endl;




//matching the numbers

//HELP!
system("pause");

}




No comments:

Post a Comment