Bublesort with vizualise in pascal
Delphi & Pascal (česká wiki)
Category: KMP (Club of young programmers)
Author: Ján Benkovič
web: www.tbteacher.host.sk
Program: Palicky.pas
File exe: Palicky.exe
Author: Ján Benkovič
web: www.tbteacher.host.sk
Program: Palicky.pas
File exe: Palicky.exe
Generate lines of different size. Next time start sort lines and draws it to next window.
{ PALICKY.PAS Copyright (c) Jan Benkovic } { Nahodne vygeneruje palicky roznych dlzok. Nasledne zacne palicky } { usporiadavat a vykreslovat do vedlajsieho okna. } { } { Datum:08.06.2000 http://www.trsek.com } Program palicky; uses crt,graph; type palicka=record farba:word; vyska:word; end; var a:array [1..50] of palicka; pom,pom1:integer; i,j:integer; gd,gm:integer; Begin detectgraph (gd,gm); initgraph (gd,gm,''); setcolor (yellow); settextstyle (4,0,5); outtextxy (250,20,'Palicky'); setcolor (white); rectangle (20,130,280,460); rectangle (340,130,610,460); settextstyle (1,0,2); outtextxy (53,100,'Pred usporiadanim'); outtextxy (408,100,'Po usporiadani'); randomize; for i:=1 to 50 do begin a[i].vyska:=random (251); a[i].farba:=random (15)+1; setcolor (a[i].farba); line (22+5*i,460-a[i].vyska,22+5*i,460); end; for j:=1 to 50-1 do for i:=1 to 50-1 do if a[i].vyska>a[i+1].vyska then begin pom:=a[i].vyska; a[i].vyska:=a[i+1].vyska; a[i+1].vyska:=pom; pom1:=a[i].farba; a[i].farba:=a[i+1].farba; a[i+1].farba:=pom1; end; readln; for i:=1 to 50 do begin setcolor (a[i].farba); line (round (342+5.2*i),460-a[i].vyska,round (342+5.2*i),460); end; readln; closegraph; end.