[Dev-C++] Print numbers up to n digits wide of number system base m.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: graeme <gr...@dr...> - 2001-11-16 03:27:59
|
m is the base system (1 < m < 11) // Base 1 doesn't make much sense...
n is the number of digits (0 < n < 81)
Set up an array of 80 chars and initialise it so that the each element is
zero except the first which is set to 1
// This is so that when you print it it will give 100000 for a six digit
number
repeat until all the numbers have been displayed
add one to the least significant digit (hence the n-1 digit in the zero
based array)
BUT {that good old c command :-) } if the current digit is equal to m - 1
then
set the current digit to 0 and try with the n-2 digit // I've left it
particularly vague for you to work out
// If you think about it you can use this to cause you repeat loop
termination condition.
Print out the number ( or each digit in the array from 0 to n-1) // Maybe
add some pauses to allow the screen to be read
end repeat // All the numbers have been displayed have a break.
|