버블 소트 베이직 코드

PhiLoSci Wiki
둘러보기로 가기 검색하러 가기
 10 let N=32
 20 dim number(N)
 30 for i=0 to N-1
 40  read number(i)
 50 next
 
100 for i=0 to N-2
110  for j=i+1 to N-1
120   if number(i)>=number(j) then temp=number(j):number(j)=number(i):number(i)=temp
130  next
140 next
150 for i=0 to N-1
160  print number(i);" ";
170 next
180 print "END"
190 end

1000 DATA 53, 12, 349, 1, 30, 90, 87, 44
1010 DATA 10, 23, 22, 535, 33, 498, 22, 109
1020 DATA 1020, 389, 32, 89, 8765, 3, 490, 20
1030 DATA 1090, 1092, 39, 22, 942, 238, 293, 11