gen_roll num_of_dice size_of_die
This compiles under gcc, Sun CC and Microsoft Visual C 1.5. Fairly generic C++, so it should compile most other places as well.
Here are executable versions. AnonFTP doesn't seem to work, so use your browser's "Save link as ..." options.
The UltraSparc version wouldn't run here on Digex's access machines, but the version I compiled here runs on the UltraSparc, go figure.
The only two tricky parts are the doubles, had to use them because the tally counter was overflowing a long, and increment().
increment() is an odometer style increment that operates on the array. Each time a digit chages, it resets all lower digits. The initial loop is to find the last digit incremented, we then increment that one, and then count down through last_ndx to do the resets.
Everything ought to be obvious.
Oh, yea. I used stdio instead of cout stream, I still have to think to use cout, my fingers can type a printf format string without actually making a brain access.