Skip to content

Instantly share code, notes, and snippets.

@drage0
Created May 10, 2016 16:55
Show Gist options
  • Save drage0/2535f4ca243c3767b94b11dc65ae26e9 to your computer and use it in GitHub Desktop.
Save drage0/2535f4ca243c3767b94b11dc65ae26e9 to your computer and use it in GitHub Desktop.
zad
PROGRAM baraba;
TYPE
niz = ARRAY[1..100] OF integer;
VAR
x: niz;
n: integer;
PROCEDURE unos(VAR x: niz; n: integer);
VAR
i: integer;
BEGIN
FOR i := 1 TO n DO
BEGIN
write('x[', i, ']=');
readLn(x[i]);
END;
END;
PROCEDURE stampa(x: niz; n: integer);
VAR
i: integer;
BEGIN
FOR i := 1 TO n DO
BEGIN
writeLn('x[', i, ']=', x[i]);
END;
END;
PROCEDURE raz(var x, y: integer);
BEGIN
IF(x>y) THEN
BEGIN
x := x + y;
y := x - y;
x := x - y;
END
ELSE
BEGIN
y := y + x;
x := y - x;
y := y - x;
END;
END;
{PROCEDURE QS(l, d: integer; VAR a: niz);
VAR
i, j: integer;
del : real;
BEGIN
IF(l < d) THEN
BEGIN
i := l;
j := d;
del := a[d];
REPEAT
WHILE(a[i] < del) DO i := i + 1;
WHILE((a[j] >= del) and (i < j)) DO j := j - 1;
IF(i < j) THEN raz(a[i], a[j]);
UNTIL (i = j);
raz(a[i], a[d]);
QS(l, i-1, a);
QS(i+1, d, a);
END;
END;}
{ AOKOKFO_Q }
BEGIN
write('n=');
readLn(n);
unos(x, n);
qs(1, n, x);
stampa(x, n);
readLn();
END.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment