Combination Program
Solved
jesper1
Posted messages
69
Status
Membre
-
yg_be Posted messages 23437 Registration date Status Contributeur Last intervention -
yg_be Posted messages 23437 Registration date Status Contributeur Last intervention -
Hello,
I would like to write a program in C that displays the different combinations you can make with the digits 0 1 2 3 4 5 6 7 8 9. The same digit can be repeated up to ten times starting from 0000000000 and then 0000000001, but so far I have only managed to write a program that displays the numbers between 0 and 9999999999 (the program works and has been running for four hours ????) but that's not really what I'm looking for, so... can you help me?
I would like to write a program in C that displays the different combinations you can make with the digits 0 1 2 3 4 5 6 7 8 9. The same digit can be repeated up to ten times starting from 0000000000 and then 0000000001, but so far I have only managed to write a program that displays the numbers between 0 and 9999999999 (the program works and has been running for four hours ????) but that's not really what I'm looking for, so... can you help me?
2 réponses
yg_be
Posted messages
23437
Registration date
Status
Contributeur
Last intervention
Ambassadeur
1 587
Hello,
can you share your program, using code tags: https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code
can you also explain the result you expect, and how it differs from the result you are getting, perhaps with an example?
maybe share the exact statement of the exercise?
can you share your program, using code tags: https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code
can you also explain the result you expect, and how it differs from the result you are getting, perhaps with an example?
maybe share the exact statement of the exercise?
yg_be
Posted messages
23437
Registration date
Status
Contributeur
Last intervention
Ambassadeur
1 587
do you want to get this?
main() { int i1,i2 ; for ( i1=0 ; i1<=9 ; i++ ) { for ( i2=0 ; i2<=9 ; i++ ) { printf ("%d%d\n", i1, i2) ; } } }
#include <stdio.h> #include <stdlib.h> main() { int i ; for ( i=0 ; i<=9999999999 ; i++ ) { printf ("%d\n", i) ; } }So basically, that's it. By running this code, the program starts listing all the numbers from 0 to 9999999999. What I want is for it to list all the ten-digit numbers (all possible combinations) that can be created with the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, considering that the same digit can be repeated up to 10 times. Basically, it will start with 0000000000 and end with 9999999999.
This exercise is personal.
the program clearly does what it was written for. what is the purpose of the personal exercise? how did you end up writing a program that seems to do not what you want to do?
do you simply want to display the insignificant zeros? if so, read this: https://docs.microsoft.com/en-us/cpp/c-runtime-library/format-specification-syntax-printf-and-wprintf-functions?view=msvc-160&viewFallbackFrom=vs-2019