pascal program唔識做 ,請幫忙!! thx

2011-03-28 6:32 am
write a program which inputs tow non-negative integers and then displays their highest common factors (H.C.F)

Sample Output 1
enter teh first integer: 12
Enter the second integer: 18
The HCG is 6

幫幫手,好急,thx~

回答 (1)

2011-03-28 6:44 am
✔ 最佳答案
var n,m,i,t:longint;beginwrite('Enter the first integer ');readln(n);write('Enter the second integer ');readln(m);while m*n<>0 do
beginif n<m thenbegint:=n;n:=m;m:=t;end;n:=n mod m;end;end;writeln('The HCG is ',n+m);end.

2011-03-27 22:47:34 補充:
n:=n mod m;
end;
end;
多左一個end;
參考: by my fd


收錄日期: 2021-04-16 12:26:58
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20110327000051KK01269

檢視 Wayback Machine 備份