2014년 12월 29일 월요일

withdraw smaller number from a list of numbers

I created a list of 5 numbers as shown in the attached image and do I remove someone with the code provided in the image attachedsuccessive

how can I get the element of fewer elements left in the list?

example:
I initially list: 1,2,3,4,5
after the for loop I list 2,4,5

how can I withdraw and then remove from the list 2
then pick up and then remove from the list 4
and finally the 5?






If your list looks like 2,1,5,4
what should it look like after your procedure?



You will need to make an extra variable to
remember the position of the smallest number
in your list.  

Call it Index_of_Smallest, and start it off at 1.
For each n from 2 to length(your list)
  If listValue at position n < listValue at position Index_of_Smallest
     then set Index_of_Smallest = n
end For loop

Delete the list item at Index_of_Smallest



Also, looking to your blocks,
if you want to keep 5 text boxes T1-T5,
you should put their component blocks into a list
at initialization time, and use the Any Textbox
blocks to manipulate them by index in that list.

That will simplify your code and reduce your block count.


댓글 없음:

댓글 쓰기