Last active
May 9, 2016 06:03
-
-
Save drage0/bb97dd401b7b3d8f8f8de6e640ba44f5 to your computer and use it in GitHub Desktop.
This file contains 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 z46; | |
TYPE niz = ARRAY[1..100] OF integer; | |
VAR | |
x: niz; | |
i, n, cNZD: integer; | |
PROCEDURE unos(n: integer; var x: niz); | |
VAR i: integer; | |
BEGIN | |
FOR i:=1 TO n DO | |
BEGIN | |
write('x[', i, ']='); | |
readLn(x[i]); | |
END; | |
END; | |
PROCEDURE stampa(n: integer; x: niz); | |
VAR i: integer; | |
BEGIN | |
FOR i:=1 TO n DO | |
BEGIN | |
write('x[', i, ']='); | |
readLn(x[i]); | |
END; | |
END; | |
FUNCTION nzd(x, y: integer): integer; | |
BEGIN | |
WHILE(x <> y) DO | |
BEGIN | |
IF(x > y) THEN x := x - y | |
ELSE y := y - x; | |
END; | |
nzd := x; | |
END; | |
BEGIN | |
write('n='); | |
readLn(n); | |
unos(n, x); | |
writeLn('--------'); | |
cNZD := nzd(x[1], x[2]); | |
FOR i:=3 TO n DO | |
BEGIN | |
writeLn('(', i, ')'); | |
cNZD := nzd(cNZD, x[i]); | |
END; | |
writeLn('NZD=', cNZD); | |
readLn(); | |
END. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment