【GCD】
[code]inputs:Num1( Numeric ),
Num2( Numeric ) ;
variables:
var0( 0 ),
var1( 0 ),
var2( 0 ),
var3( 0 ) ;
var0 = AbsValue( Num1 ) ;
var1 = AbsValue( Num2 ) ;
condition1 = var0 = 0 or var1 = 0;
if condition1 then
var3 = 0
else
begin
var2 = MinList( var0, var1 ) ;
while var2 <> 0
begin
var3 = var2 ;
if var0 > var1 then
begin
var2 = Mod( var0, var1 ) ;
var0 = var2 ;
end
else if var1 > var0 then
begin
var2 = Mod( var1, var0 ) ;
var1 = var2 ;
end
else
var2 = 0 ;
end ;
end ;
GCD = var3 ;
[/code]
页:
[1]