A
A
AlexFarsh2020-12-03 19:22:13
Pascal
AlexFarsh, 2020-12-03 19:22:13

How to sort a multidimensional array using selection sort?

How to sort by the selection method, no matter how it turns out to sort:

spoiler
program SortBubble;
const
    n=10;
var
    x: array[1..n,1..n] of integer;
    i,j,max,min: integer;
begin

    {Заполнение массива}
    randomize;
    for i:=1 to n do begin
        for j:=1 to n do begin
            x[i,j]:=random(100);
            write(x[i,j]:5);
        end;
        writeln
    end;
    
    writeln;
    
    {Сортировка массива}
    
    for i:=1 to n do begin
        max:=x[i,1];
        for j:=1 to n-1 do begin
            if max>x[j+1,1] then begin
                min:=x[i,1];
                x[i+1,1]:=max;
            end; 
        end;
        writeln(x[i,1]);
    end; 
    
end.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question