Skip to content

Instantly share code, notes, and snippets.

@drage0
Last active May 9, 2016 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drage0/bb97dd401b7b3d8f8f8de6e640ba44f5 to your computer and use it in GitHub Desktop.
Save drage0/bb97dd401b7b3d8f8f8de6e640ba44f5 to your computer and use it in GitHub Desktop.
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