a lottery ticket buyer purchases 10 tickets a week, always playing the same 10 5
ID: 3643838 • Letter: A
Question
a lottery ticket buyer purchases 10 tickets a week, always playing the same 10 5-digit "lucky" combinations. Write a program that initializes an array with these numbers and then lets the player enter this weks winnings 5-digit number. the program should perform a linear search through the list of the players numbers and report whether or not one of the tickets a winner this week.13579 26791
26792 33445 55555 62483 77777 79422 85647 93121
also show
psuedocode
flow chart
screen shot
description of what had to change from the initial plan
Explanation / Answer
#include<iostream>
using std::cout;
using std::endl;
using std::cin;
int main(int argc, char *argv[])
{
int loop, counter = 10;
int thisresult[50] = {11,18,20,24,25,
8,10,23,32,36,
1,6,12,18,34,
23,29,31,32,34,
1,15,17,23,32,
4,6,13,25,27,
8,9,26,29,34,
14,17,19,24,30,
1,8,25,28,29,
13,17,24,29,33};
// This week lottery result
int number_lottery;
// Number of user lottery
cout << "How many numbers : ";
cin >> number_lottery;
int *user_lottery = new int[number_lottery];
for (loop=0;loop{
cout << "Enter the lottery Number : ";
cin >> *(user_lottery + loop);
}
cout << " Comparison is being processed ";
counter = 10;
while(counter > 0)
{
cout << counter << "!" << " ";
counter--;
}
// -------------------------------------
// Comparison Part/Linear Search
for (loop=0;loop<10;loop++)
{
if ( *(user_lottery + loop) == thisresult[loop] )
{
cout << " CONGRATULATIONS, YOU ARE THE WINNER!";
cout << " The number is " << *(user_lottery + loop);
}
}
delete [] user_lottery;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.