
Untitled
By: a guest on
May 13th, 2012 | syntax:
Pascal | size: 1.82 KB | hits: 18 | expires: Never
uses crt, graph, sysutils;
const N = 10;
var
ster, tryb, k, i, j, p, x, q: integer;
d : array[1..N] of integer;
s, t: string;
procedure heart(x, y: integer);
begin
line(x-50, y-20, x, y+35);
line(x, y+35, x+50, y-20);
arc(x-25, y-20, 0,180, 25);
arc(x+25, y-20, 0,180, 25);
SetFillStyle ( SolidFill, 4 );
floodfill( x, y, 4);
end;
begin
detectgraph(ster,tryb);
initgraph(ster,tryb, 'C:\tp\bgi');
randomize;
for i := 1 to N do d[i] := random(100);
setbkcolor(darkgray);
SetTextStyle ( 1, HorizDir, 2 );
k:=0;
for j := N - 1 downto 1 do
begin
p := 1;
for i := 1 to j do
if d[i] > d[i+1] then
begin
x := d[i]; d[i] := d[i+1]; d[i+1] := x;
p := 0;
k:= k+1;
s:= 'krok ' + inttostr(k);
t:= 'Sortowanie babelkowe!';
cleardevice();
outtextxy( (getmaxx-TextWidth(s)) div 2, 80, s);
outtextxy( (getmaxx-TextWidth(t)) div 2, 120, t);
for q:=1 to N do
begin
outtextxy( ( (getmaxx - textwidth( inttostr(d[q]) ) ) div (N+1)) * q, ( 400 - textheight( inttostr(d[q]) ) ), inttostr(d[q]) );
end;
setcolor(red);
heart(( getmaxx div (n+1)) * i, 400);
heart((getmaxx div (n+1)) * (i+1), 400);
{outtextxy( ( (getmaxx - textwidth( inttostr(d[q]) ) ) div (N+1)) * q, ( 400 - textheight( inttostr(d[q]) ) ), inttostr(d[q]) );}
delay(500);
end;
if p = 1 then break;
end;
cleardevice();
outtextxy( (getmaxx-TextWidth(s)) div 2, 80, s);
outtextxy( (getmaxx-TextWidth(t)) div 2, 120, t);
for q:=1 to N do
begin
outtextxy( ( (getmaxx - textwidth( inttostr(d[q]) ) ) div (N+1)) * q, ( 400 - textheight( inttostr(d[q]) ) ), inttostr(d[q]) );
end;
setcolor(lightgreen);
s:='Well done!';
outtextxy( (getmaxx-textwidth(s)) div 2, 600, s );
delay(5000);
CloseGraph;
end.