+ 8

here is my small challenge :

Write a function that has a self-call, with n receiving an integer greater than 1 and typing all the binary numbers to a length of n from the smallest to the largest except for the numbers with zero consecutive digits For example, if n = 3 is printed: 010 011 101 110 111

17th Dec 2017, 8:31 AM
ABADA S
ABADA S - avatar
11 Réponses
+ 5
yes there is no 00
17th Dec 2017, 9:48 AM
ABADA S
ABADA S - avatar
+ 5
there must not be any 00 in output just 11,010,110...etc
18th Dec 2017, 4:48 PM
ABADA S
ABADA S - avatar
+ 5
no once follow the basic condition , you must use self-call method
4th Jan 2018, 10:04 PM
ABADA S
ABADA S - avatar
+ 4
https://code.sololearn.com/cfJZSooz6Co0/?ref=app My try. Not too shabby I guess...
17th Dec 2017, 12:38 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 4
thanks for all but there is no one use recall methods like string a(int x){some code and a(x-1)} for example
18th Dec 2017, 5:02 PM
ABADA S
ABADA S - avatar
+ 3
Here’s another version with a recursive method: https://code.sololearn.com/WB6YVa1Q4Re0/?ref=app
18th Dec 2017, 7:16 PM
Luc Hariman Randrianomenjanahary
Luc Hariman Randrianomenjanahary - avatar
17th Dec 2017, 10:42 AM
Luc Hariman Randrianomenjanahary
Luc Hariman Randrianomenjanahary - avatar
+ 2
When n = 5, these are invalid, right? 01001 10010 00111 11000 10001 etc...
17th Dec 2017, 12:10 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
https://code.sololearn.com/cTxG6cjdmuvP/?ref=app This is my try in C++ @ABADA S Now inside my function 'calcula(int n)' there is a call to 'calcula(n-1)'. Thanks for your comments. And now progressive... https://code.sololearn.com/chqWQkVWEhqS/?ref=app
17th Dec 2017, 5:06 PM
Enrique
+ 1
@ABADA S Shouldn't the program print 100 and 001 as well?
17th Dec 2017, 8:58 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar