# Chapter 8 Lottery Winners

/*

2. Lottery Winners
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  or  a vector  with these numbers and then lets the player enter this weeks winning 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 is a winner this week. Here are the numbers:
13579  26791  26792  33445  55555
62483  77777  79422  85647  93121

*/

#include “stdafx.h”
#include<iostream>
#include<vector>

using namespace std;

int main()
{
vector<int> lotteryList;

//Store values in the vector.
lotteryList.push_back(13579);
lotteryList.push_back(26791);
lotteryList.push_back(26792);
lotteryList.push_back(33445);
lotteryList.push_back(55555);
lotteryList.push_back(62483);
lotteryList.push_back(77777);
lotteryList.push_back(79422);
lotteryList.push_back(85647);
lotteryList.push_back(93121);

//get winning number
int winningNumber;

cout<<“Enter this week’s winning number “;
cin>>winningNumber;

for(int i=0;i<10;i++)
{
if(lotteryList[i]==winningNumber)
{
cout<<“One of the tickets is a winner this week.”<<endl;

break;
}else if(i==9) cout<<“Not one of the tickets is a winner this week.”<<endl;
}

system(“pause”);
return 0;
}