A
A
Anton Ivanov2015-09-28 20:05:44
C++ / C#
Anton Ivanov, 2015-09-28 20:05:44

What algorithm can iterate over decimal numbers with repetitions?

It is required to enumerate all four-digit decimal numbers in which each next digit does not exceed the previous one and implement the solution in C/C++.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Kitaev, 2015-09-28
@realradzatebya

int result, i, j, k, l;
for (i=1;i<=9;i++)
    for (j=0;j<=i;j++)
        for (k=0;k<=j;k++)
            for (l=0;l<=k;l++) {
                result = i*1000 + j*100 + k*10 + l;
                cout << result << endl;
            }

A
abcd0x00, 2015-10-01
@abcd0x00

You can make a function
and feed numbers into it in order.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question