All pastes #464316 Raw Edit

Untitled

public text v1 · immutable
#464316 ·published 2007-04-29 13:04 UTC
rendered paste body
//Robertas Jurkaitis, 6 grupe, uzduotis 3, variantas 8
program ketvirta;
uses DOS;
type mas = array [1..1000] of integer;

procedure burbulas(var arr:mas; a:integer);
var b, c, f:integer;
    e, g:longint;
    t1, t2, t3, t4, t5, t6, t7, t8:word;

begin
    gettime(t1, t2, t3, t4);
    writeln('Programos darbo pradzia: ', t1, 'h ', t2, 'min ', t3, 'sec ', t4, 'ms');
    e:=0;
    g:=0;

    for b:=1 to a do
    begin
        for c:=1 to a do
        begin
            e:=e+1;
            if arr[c+1]>arr[c] then
            begin
                f:=arr[c+1];
                arr[c+1]:=arr[c];
                arr[c]:=f;
                g:=g+1;
            end;
        end;
    end;

    writeln();
    writeln();
    writeln('Palgyinimu skaicius: ', e);
    writeln('Keitimu skaicius: ', g);
    writeln();

    gettime(t5, t6, t7, t8);
    writeln('Programos darbo pabaiga: ', t5, 'h ', t6, 'min ', t7, 'sec ', t8, 'ms');
    if t7>t3 then
    if t4<t8 then t1:=-t4-t8;
    writeln('Algoritmas atliktas per ', t1);
end;

var a, b:integer;
    arr:mas;
    failas:text;
begin
    assign(failas, 'U:\Projektai\failas.txt');
    rewrite(failas);

    writeln('Iveskite norima masyvo elementu skaiciu: ');
    readln(a);

    randomize;
    for b:=1 to a do arr[b]:=random(1000);
    burbulas(arr, a);
    for b:=1 to a do write(failas, arr[b], ' ');
    close(failas);
    readln();
end.