fork download
  1. //Cecilia Rangel CSC5 Chapter 8, P.487, #2
  2. //
  3. /**************************************************************
  4.  *
  5.  * COMPUTE WINNING TICKET
  6.  * ____________________________________________________________
  7.  * This program will randomly generate 5 number between 1 and 9 in
  8.  * an array for a lottery ticket.
  9.  *
  10.  *_____________________________________________________________
  11.  * INPUT
  12.  * user[SIZE] : INPUT the 5 digits of the user.
  13.  *
  14.  * OUTPUT
  15.  * lottery[SIZE] : OUTPUT the 5 digits of the lottery(randomnize)
  16.  * ***************************************************************/
  17. #include <iostream>
  18. #include <iomanip>
  19. using namespace std;
  20.  
  21. int main() {
  22. int luckyComb[10] = {13579, 62483, 26791, 77777, 26792,
  23. 79422, 33445, 85647, 55555, 93121};
  24. int winningComb; //INPUT - the week's winning combination
  25. int count; //counter for the array's elements
  26. int position; //tracks the position in the array
  27. bool found; //flag whether or not value was found
  28. //
  29. //Promt the user to enter the week's winning combination
  30. cout << "Enter the current week's winning lottery combination.\n";
  31. cin >> winningComb;
  32. //
  33. //Loop to find whether the user has a winning ticket
  34. position = -1;
  35. found = false;
  36. for (count = 0; count < 10; count++)
  37. {
  38. if (winningComb == luckyComb[count])
  39. {
  40. found = true;
  41. position = count;
  42. cout << "You have a winning combination.\n";
  43. }
  44. }
  45. if (!found)
  46. cout << "You don't have a winning combination.\n";
  47. return 0;
  48. }
Success #stdin #stdout 0.01s 5352KB
stdin
Standard input is empty
stdout
Enter the current week's winning lottery combination.
You don't have a winning combination.