Cod sursa(job #2325342)
Utilizator | Copetchi Dumitru CopDumitru | Data | 22 ianuarie 2019 15:45:34 |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 30 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
program Ex1;
var
f, g: text;
T, a, b, i: integer;
function cmmdc(x, y: longint): longint;
begin
while x <> y do
if x>y then x:=x-y else y:=y-x;
cmmdc:=x;
end;
begin
assign(f, 'euclid2.in'); reset(f);
readln(f, t);
assign(g, 'euclid2.out'); rewrite(g);
for i := 1 to t do
begin
Readln(f, a, b);
writeln(g, cmmdc(a, b));
end;
close(f);
close(g);
end.