Answer the question
In order to leave comments, you need to log in
How to put the program in unit and connect it?
Exercise:. Given a matrix A of order n. Arrange the elements of each row in ascending order.
The code is working, I can't put the procedures in the unit correctly, please help!
uses
SysUtils;
Const
xmin=1;
xmax=1000;
Type
Matrix=array[xmin..xmax,xmin..xmax] of Integer;
{Ïðîöåäóðà äëÿ âûâîäà èñõîäíîé ìàòðèöû íà ýêðàí}
Procedure BM(var a:Matrix;x:Integer);
Var
i,j:Integer;
Begin
Writeln('Isxodnaya matrica:');
For i:=1 to x do
Begin
Writeln;
For j:=1 to x do
Write(' ',a[i,j],' ')
End;
Writeln;
End;
{Êîíåö ïðîöåäóðû âûâîäà íà ýêðàí}
{Ïðîöåäóðà ñîðòèðîâêè ñòðî÷åê ïî âîçðàñòàíèþ}
Procedure CCTPB(var a: array of integer;x:Integer);
Var
i,j,c:Integer;
Begin
For i:=0 to x - 2 do
For j:=i+1 to x - 1 do
If a[i]>a[j] then
Begin
c:=a[i];
a[i]:=a[j];
a[j]:=c
End
End;
{Êîíåö ïðîöåäóðû ñîðòèðîâêè ïî óáûâàíèþ}
Var
a:matrix;
i,j,x,f,v:Integer;
Begin
randomize;
Repeat
Write('VVedite razmer kvadratnoy matrici v diapazone s ',xmin,' do ',xmax,' : ');
Readln(x);
Until (x>xmin) and (x<xmax);
Writeln('Kak vvesti matricy?');
Repeat
Writeln('1 - Avtomaticheskiy vvod matrici ');
Writeln('2 - Rychnoy vvod matrici');
Writeln;
Readln(f);
Until (f<3) and (f>0);
{Çàäàíèå ìàòðèöû}
If f = 1 then
{Àâòîìàòè÷åñêèé ââîä}
Begin
Writeln;
Write('Vvedite verhnee chislo dlya generatora slychaynih chisel: ');
Readln(v);
For i:=1 to x do
Begin
For j:=1to x do
Begin
a[i,j]:=Random(v);
End;
End;
End
Else
{Ðó÷íîé ââîä}
Begin
For i:=1 to x do
Begin
For j:=1 to x do
Begin
Writeln('Vvedite element', i, ' stroki i ', j, ' stolbca: ');
Readln(a[i,j]);
End;
End;
End;
{Êîíåö çàäàíèÿ ìàòðèöû}
BM(a,x);
for i:=1 to x do CCTPB(a[i],x);
Writeln;
Writeln('Sortirovka ctrok v poryadke vozrastaniya');
Writeln;
Write('Izmenennaya matrica:');
For i:=1 to x do
Begin
Writeln;
For j:=1 to x do
Write(' ',a[i,j],' ') ;
readln;
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 questionAsk a Question
731 491 924 answers to any question