Re: lottery number thing problem
From: Andreas Goebel (a-goebel_at_at__gmx.de)
Date: 11/12/03
- Next message: Harsha: "How to find Memory Leak"
- Previous message: jeffc: "Re: Resume the computation after an exception"
- In reply to: Chris Theis: "Re: lottery number thing problem"
- Next in thread: Centurion: "Re: lottery number thing problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 12 Nov 2003 22:32:17 +0100
Chris Theis wrote:
> "Chris Dams" <chrisd@gamow.sci.kun.nl> wrote in message
> news:bot232$ekd$1@gamow.sci.kun.nl...
>
>>Hello,
>>
>
> [SNIP]> > while (num_count <=5) //i.e. while all 6 numbers have not yet been
> drawn.
>
>>> {
>>> //initialise random number generator
>>> time_t t;
>>> srand(unsigned (time(&t)));
>>
>>The srand should not be inside the loop. Move it out of it.
>>
>
> [SNIP]
>
> I'd even suggest to move it out of the whole function into main() 'cause
> there is certainly no point in re-seeding the RNG and this might become a
> pitfall sometime later!
>
> Regards
> Chris
>
>
Hello,
I donīt know if I am leading the original poster to far away, but as
this surely is a c++ listing I would do this completely different:
- create a set, put the 49 Numbers into it
- do a random shuffle with the set
- get the first six numbers out of the set and put them in a vector
- sort the vector, cout the numbers
You will need to read the documentation to the following headers:
<set>
<vector>
<algorithm> - you need that for the random shuffle and for the sorting
(look for random_shuffle and sort).
If you want to do the actual sorting yourself you will need a sorting
algorithm. You can learn very much if you try to invent your own. How
would you sort playing cards? If you want to program this yourself you
should stick to the array.
Best regards, Andreas
- Next message: Harsha: "How to find Memory Leak"
- Previous message: jeffc: "Re: Resume the computation after an exception"
- In reply to: Chris Theis: "Re: lottery number thing problem"
- Next in thread: Centurion: "Re: lottery number thing problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|