-
October 15th, 2012, 05:00 AM
#31
Re: A task involving linked lists and a headache
Originally Posted by MustSeeMelons
rand()%4 would give me 0-4
Actually, it will give you integers in the range [0, 3].
-
October 15th, 2012, 05:14 AM
#32
Re: A task involving linked lists and a headache
-
October 15th, 2012, 06:46 AM
#33
Re: A task involving linked lists and a headache
Originally Posted by MustSeeMelons
Forgot to delete that pointer for the bunny, anyway, it wasnt used.
Because, rand()%4 would give me 0-4, but those positions contain Male names, i need rand()%(14 - 10)+10 gives me 10-14, which are the names i need.
Good grief.
rand() % 4 + 10.
The (14 - 10) just evaluates to 4. Why not just write 4? Why not (107 - 103)? Keep it as simple as possible.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|