Generate all possible 5-bit binary combinations
Solved
Maxxx
-
Maxxx -
Maxxx -
Hello, I would like to write a program to generate all the combinations of size five in binary
example:
00000
00001
00010
00011
00100
00101
00110
00111
...
11111
But I don't know exactly how to go about it, at first I wanted to use a tree structure but I'm not very good at that. Do you have a simpler idea (with an array for example) to do this?
Thank you in advance.
example:
00000
00001
00010
00011
00100
00101
00110
00111
...
11111
But I don't know exactly how to go about it, at first I wanted to use a tree structure but I'm not very good at that. Do you have a simpler idea (with an array for example) to do this?
Thank you in advance.
1 answer
-
Hello, in what context are you doing this?
-
-
-
1) Each binary number represents a decimal number in the usual order, which means that:
00000=> 0
00001 => 1
00010 =>2
00011 =>3
00100 =>4
...
11111=>(2^5)-1=31
2) I know that we need to start from 100 and stop at 999, but I don't see how, among all decimal digits, we can select only those with 3 digits. -
-
-