#10799: 請大家幫看一下 我差在哪裡??


873573823 (7vinbaby)

學校 : Bishop Hall Jubilee School
編號 : 51622
來源 : [58.176.14.251]
最後登入時間 :
2016-07-13 20:31:08
a024. 最大公因數(GCD) | From: [58.176.14.251] | 發表日期 : 2016-03-20 18:33

var count,x,y,target:longint;
begin
while not eof do begin
readln(x);
readln(y);
target:=0;
if x>y
then begin
for count:=1 to (y-1) do
begin
if ((x mod count)=0) and ((y mod count)=0)
then target:=count;
end;
end;
if y>x
then  begin
for count:=1 to (x-1) do
begin
if ((x mod count)=0) and ((y mod count)=0)
then target:=count;
end;
end;
writeln(target);
end;
end.

 
ZeroJudge Forum