Jump to content

Hey, so I made this program in free pascal  : 
PROGRAM foruthtask;
USES CRT;
CONST K=20  ;
VAR A : ARRAY[1..K,1..K] OF INTEGER;
N, M, I, J:INTEGER;
Z,X:INTEGER;
BEGIN
CLRSCR;
WRITE('rows N:');
READLN(N);
WRITE('columns M:');
READLN(M);
RANDOMIZE;
FOR I:=1 TO N DO
FOR J:=1 TO M DO A[I,J]:=RANDOM(61)-10;
WRITELN('MASVS A:');
FOR I:=1 TO N DO BEGIN
WRITELN;
FOR J:=1 TO M DO
WRITE(A[I,J]:4);
END;
READLN;
END.


And I have to put bubblesort into this, so it sorts numbers ascending, can someone please help?

Link to comment
https://linustechtips.com/topic/591983-looking-for-some-help/
Share on other sites

Link to post
Share on other sites

Pseudocode:

procedure bubbleSort( A : list of sortable items )
   n = length(A)
   repeat 
     swapped = false
     for i = 1 to n-1 inclusive do
       /* if this pair is out of order */
       if A[i-1] > A[i] then
         /* swap them and remember something changed */
         swap( A[i-1], A[i] )
         swapped = true
       end if
     end for
   until not swapped
end procedure

 

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
https://linustechtips.com/topic/591983-looking-for-some-help/#findComment-7703036
Share on other sites

Link to post
Share on other sites

On 6.5.2016. at 10:55 AM, Gachr said:

Pascal isn't used much any more, you'd be better off asking at Pascal-specific places or just switch to another, more popular language.

 

BTW: 1000th post, yay ;D

it's for school, thats why we have to use pascal...:/

Link to comment
https://linustechtips.com/topic/591983-looking-for-some-help/#findComment-7732531
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×