You are here:

C++/lottery numbers


Hi Vijayan
It has been a while since i have done any work with c++ and i was wondering if you could help me out with this problem

i have one hundred and fifty lottery tickets each ticket has 6 numbers if i want to check against wining lotto numbers for150 past weeks of 6 sets of winning numbers how would i write the syntax.
an example of what i would expect to see is if number matching to display number else display "p"
anything visible of printable is sufficient.

Many thanks

represent each ticket as an array of 6 numbers.
and since we have 150 tickets, have an array tickets, each having an array containing 6 numbers.
in other words, a two-dimensional array:

enum { NUMBERS_PER_TICKET = 6, NUM_TICKETS = 150 } ;

int tickets[  NUM_TICKETS ] [ NUMBERS_PER_TICKET ] ;

tickets[i] ( 0 <= i < NUM_TICKETS ) would get you to ticket number i.

tickets[i][j] ( 0 <= j < NUMBERS_PER_TICKET ) would get you to the jth number on ticket i.

to check if a number is in any of the tickets, write a nested loop; the index of the outer loop being i and that of the inner loop being j.  


All Answers

Answers by Expert:

Ask Experts




my primary areas of interest are generic and template metaprogramming, STL, algorithms, design patterns and c++11. i would not answer questions about gui and web programming.


about 15 years or so

post graduate engineer

©2017 All rights reserved.

[an error occurred while processing this directive]