Created
May 10, 2016 16:55
-
-
Save drage0/2535f4ca243c3767b94b11dc65ae26e9 to your computer and use it in GitHub Desktop.
zad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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