Answer the question
In order to leave comments, you need to log in
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
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;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question