Cod sursa(job #2295408)
Utilizator | Daniela Vornic danielavornic | Data | 3 decembrie 2018 17:22:39 |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 30 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.56 kb |
program p1;
var fIn, fOut : textfile;
t, a, b, d, i: integer;
begin
assign(fin, 'euclid2.in');
assign(fout, 'euclid2.out');
reset(fin);
rewrite(fout);
readln(fin, t);
for i := 1 to t do
begin
read(fin, a);
readln(fin, b);
if (a < 0) then a := -a;
if (b < 0) then b := -b;
while not (a = b) do
begin
if (a > b) then a := a - b
else b := b - a;
end;
d := a;
writeln(fout, d);
end;
close(fin);
close(fout);
end.