R
Richard
Keith Thompson said:[...]Bill Cunningham said:Wow. I think Richard says later in the thread that this kind of code is
dazzling and it is. Maybe something simple like the permutations of 1234.
That can be done by hand but how does C do it is the question.
You keep talking about "permutations". Are you sure that's the right
word? To be blunt, are you sure you know what the word means?
There are 24 permutations of 1234. Here they are:
1234 1243 1324 1342 1423 1432
2134 2143 2314 2341 2413 2431
3124 3142 3214 3241 3412 3421
4123 4132 4213 4231 4312 4321
(I did these manually, so there may be some errors.)
There are two important things to note. First, there are N! (N
factorial) permutations of N items; 4! is 24. Second, the definining
characteristic of each permutation is that no item is repeated.
You've been asking about 16 digits, with 10 possible values for each
digit. Given that description, there can be *no* permutations.
I've been able to figure out that you want to do *something* that
involves 16-digit decimal numbers (similar to credit card numbers).
I'm not sure whether you want to generate them randomly, generate all
possible numbers, or something else. I have no idea whether you want
to print each one as it's generated, or store them all, or do
something else.
Numerous people have spent considerable time and effort trying to help
you, based on *guesses* about what you're asking for. Throughout
this, you have been unable or unwilling to tell us just what you're
trying to do.
You have been wasting your time and ours.
Tell us what you want to do, and we'll try to help you do it.
Otherwise, I'm done.
He most certainly does not want to "randomly" generate all possible
numbers since that is just 0 to 16^10-1 anyway.
I suspect what he wanted was something completely different in order to
play with pointers and malloc.
On the other hand he might just wanted to have stored a single credit
card number.
Who knows? He most certainly doesn't. And as I, rather sagely if I say
so myself, pointed out people like Santosh throwing (uncommented) code
at an ill defined problem did nothing whatsoever to help anybody - least
of all Bill.