Combination Program
Solved
jesper1
Posted messages
69
Status
Member
-
yg_be Posted messages 23437 Registration date Status Contributor Last intervention -
yg_be Posted messages 23437 Registration date Status Contributor 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 answers
-
yg_be Posted messages 23437 Registration date Status Contributor Last intervention Ambassadeur 1 588
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?-
It's a very simple program based on the "for" loop.
#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. -
you do not explain precisely how what you obtain diverges from what you wish to obtain. maybe show an example.
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 -
The program I wrote does what it's supposed to do and lists the numbers between 0 and 9999999999. I'm just saying that's what I managed to do. What I want is a program that takes the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and combines them in different ways to form a ten-digit number (from 0 to 9). Basically, I want a program that lists all the ten-digit numbers that can be formed with 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. The first numbers in the list should be 0000000000 followed by 0000000001 followed by 0000000002 followed by 0000000003 followed by 0000000004 and so on. The last ones will be 9999999997 followed by 9999999998 and finally 9999999999.
-
-
-
-
yg_be Posted messages 23437 Registration date Status Contributor Last intervention Ambassadeur 1 588
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) ; } } }