Monday, March 22, 2010

Sort N numbers

private subcommand 1-click
rem sort N numbers in ascending order
Dim a(1 to 10)as integer
Dim N,i,j,t as integer
Rem input
n=inputbox("enter the total elements")
for i=1 to N
a(i)=inputbox("enter the elements one by one")
list1.additem a(i)
next i
rem calculation
for i=1 to n-1
for j=i+1 to n
if a(i)>A(j)then
t=a(i)
a(i)=a(j)
end if
next j
next i
rem output
print "output order;ascending order"
list2.additem a(i)
next i
text 1=a(n)
text 2=a(n-1)
text 3=a(1)
text 4=a(2)
end sub

No comments:

Post a Comment