;~ int GCD(int,int);//傳回最大公因數值
;~ int main()
;~ {
;~ int m,n,x,y,z;
;~ cout << "小於100的畢氏三元數:" << endl;
;~ for(m=2;m<=9;m++)
$time = TimerInit()
$r = ""
;~ {
For $m = 2 To 9
;~ for(n=m-1;n>0;n-=2)
;~ {
$n = $m - 1
While $n > 0
;~ if(GCD(m,n)==1)
;~ {
If _GCD($m, $n) == 1 Then
;~ x=m*m-n*n;
$x = $m ^ 2 - $n ^ 2
;~ y=2*m*n;
$y = 2 * $m * $n
;~ z=m*m+n*n;
$z = $m ^ 2 + $n ^ 2
;~ if(z<=100)
If $z <= 100 Then
;~ cout << x << "\t" << y << "\t" << z << endl;
$r &= $x & ' ' & $y & ' ' & $z & @CRLF
;~ }
EndIf
;~ }
EndIf
;~ }
$n -= 2
WEnd
Next
;~ system("pause");//程式暫停
;~ return 0;
MsgBox(0, TimerDiff($time), $r)
;~ }
;~ int GCD(int m,int n)
;~ {
Func _GCD($m, $n)
While Mod($m, $n) <> 0
$temp = $m
$m = $n
$n = Mod($temp, $n)
WEnd
Return $n
EndFunc ;==>_GCD
结果返回不正常.... |