Pagini recente » Cod sursa (job #2980085) | Cod sursa (job #3272143) | Cod sursa (job #1887919) | Cod sursa (job #1949329) | Cod sursa (job #1949430)
{Program Euclid;
var A,B,C,i,t: Longint;
f,g: text;
begin
assign(f,'euclid2.in');
assign(g,'euclid2.out');
reset(f);
rewrite(g);
read(f,T);
if A < B then begin
C:= A;
A:= B;
B:= C;
end;
for i:=1 to t do begin
read(f,A,B);
while B <> 0 do begin
C:= A mod B;
A:= B;
B:= C;
end;
writeln(g,A);
end;
close(f);
close(g);
end.}
var f,g:text;
t,i,a,b,r:longint;
begin
assign(f,'euclid2.in');reset(f);
assign(g,'euclid2.out');rewrite(g);
readln(f,t);
for i:=1 to t do
begin
readln(f,a,b);
if a<b then begin r:=a;a:=b;b:=r;end;
repeat
r:=a mod b;
a:=b;
b:=r;
until r=0;
writeln(g,a);
end;
close(f);
close(g);
end.