Thứ Ba, 3 tháng 5, 2022

TRUNGVI PAS

const fi='TRUNGVI.inp';fo='TRUNGVI.out';
var a,b:array[1..100] of longint;
    i,j,n:longint;

procedure sort_b;
var i,j,tam:longint;
begin
    for i:=1 to n do
        for j:=i+1 to n do
            if b[i]>b[j] then
            begin
                tam:=b[i];
                b[i]:=b[j];
                b[j]:=tam;
            end;
end;

procedure sort_a;
var i,j,tam:longint;
begin
    for i:=1 to n do
        for j:=i+1 to n do
            if a[i]>a[j] then
            begin
                tam:=a[i];
                a[i]:=a[j];
                a[j]:=tam;
            end;
end;

begin
    assign(input,fi);reset(input);
    assign(output,fo);rewrite(output);
    readln(n);
    for j:=1 to n do
    begin
        for i:=1 to n do read(a[i]);
        sort_a;
        b[j]:=a[n div 2+1];
    end;
    sort_b;
    writeln(b[n div 2+1]);
end.

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.