LCD / GCD 是基本算法,尽量自己做,家长赚钱不容易的,,,
Local x
Local Y
Local g
x = 122
&& Read Numerator
Y = 990
&& Read Denominator
*!*
g = 1
*!* Display the given fraction
Messagebox("Original Fraction: " + Transform(x) + " / " + Transform(Y))
*!* Calculate GCD
g = gcd(x, Y)
*!* Reduce the fraction
X = X / g
Y = Y / g
*!* Display result
Messagebox("Reduced Fraction: " + Transform(x) + " / " + Transform(Y))
*!***************************************
*!* Name: GCD - Reduce a Fraction
*!* Description:The proper way to reduce a fraction to simplest terms. (For example, 12/32 reduces to 3/8) Divide both the numerator and the denominator by the
greatest common divisor of the numerator and denominator. Most programmers are familiar with this GCD algorithm. If this is new to you, take a moment to understand
what this does and how it can be used. It comes in handy!
*!* By: korejwa
*!*
*!*This code is copyrighted and has&& limited warranties.Please see http://www.
details.&&**************************************
Function gcd(X, Y )
gcd = 0
If X < 0
X = -x
&& Euclid's Algorithm
Endif
If Y < 0
Y = -Y
&& Returns Greatest Common Divisor of x and y
Endif
If X = 0 Or Y = 0
? "Math Error in GCD"
&&If both x and y are zero ...
Endif
gcd = Y
Do While X > 0
gcd = X
x = Y % X
Y = gcd
Enddo
Return gcd
Endfunc
团队红星二锅头,队长王猛,领队李冲,顾问杨伟,副队张挺,外联马彪,内勤韩秀,人事顾闯,财务赵魁,后勤周强