Book of tasks on programming. Old version

 

 by Aliaksandr N. Prykhodzka

 

floppy, to, interrupt, byte, row, library, USB, лекция, procedure, NTFS, двоичный, query, подсказка, number, keyboard, function, hierarchy, сохранить, text, external
 

for valuable work you must have JavaScript (allow active content)

Pascal. Pb.4. Nest of tasks. Sorting

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pb.4.1     Answer

Determine content of array Dragon at the end of the following program.


Program AA;
uses
crt, dos;
var
    Dragon : array[1..10] of integer;
    i, j, k : integer;
begin
    Randomize;
    for i:=1 to 10 do Dragon[i]:=Random(100)+i*100;
    while Dragon[10]>0 do begin
        for i:=9 downto 1 do
            Dragon[i+1]:=Dragon[i+1]-Dragon[i];
        for i:=9 downto 1 do
            for j:=1 to i do
                if Dragon[j]>Dragon[j+1] then begin
                    k:=Dragon[j];
                    Dragon[j]:=Dragon[j+1];
                    Dragon[j+1]:=k;
                end;
        Dragon[10]:=Dragon[9];
    end;
end.

 

©   Aliaksandr Prykhodzka    1993 - 2007