Re: Sequence items to a single number ? How to achieve ?

new topic     » goto parent     » topic index » view thread      » older message » newer message
Selgor said...

Hello

Selgor here

I should have given you the code

Sorry

Where would you put your code in the following
I tried but no work
It is me NOT your code

Thank you for replying
Cheers

Anticipating your reply

programme:=

include get.e  
                     
sequence  seq = {} 
-- seq = repeat(0,30)  don't need this line. let sequence grow as needed 
 
object number,n1,w --times  
number = 0 
-- times = 0 
n1 =0  
   
number = prompt_number("Type a number then enter  ",{})  
n1 = number  
       
while n1 != 0 do  
--	times += 1 don't need  
--	seq[times] = remainder(n1,2)  
	seq = prepend(seq, remainder(n1,2)) 
	n1 = floor(n1/2)  
end while  
 
puts(1,"\n") 
 
for i = 1 to length(seq) do  
	puts(1,"Seq =") 
	printf(1,"%4d",seq[i]) 
	puts(1,"\n")  
end for  
/*Now as to the formatting of the output\\ 

I thought you wanted to take a sequence such as {1, 0, 1, 1, 0, 1, 1} and print it out as '1011011' if so you would use  
seq += 48    
printf(1,"%s\n",{seq})                                                                                                    
*/ 
 
w= wait_key() 

Hi Selgor,

I cleaned up the formatting of the code and made a few changes. Check the comment block at the end and see if that is what you want.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu