请教:
代码如下,不知错在何处,得不到要的结果
@echo off
rem 求36与另一个正整数(少于36)的最大公约数
:start
set y=36
set /p x= 输入小于36的正整数:
:divisor
set /a y=%y%%%%x%
if %y%==0 set mcdivisor=%x% && goto :display
set x=%x%%%%y%
if %x%==0 set mcdivisor=%y% && goto :display
goto :divisor
:display
echo mcdivisor:%mcdivisor%
pause
goto :start
[ Last edited by donpps on 2007-1-13 at 02:13 AM ]
@echo off
echo.
echo 求两数的最大公约数
echo ================================
title 求两数的最大公约数
setlocal enabledelayedexpansion
set /p num1=请输入第一个数字:
set /p num2=请输入第二个数字:
echo --------------------------------
echo %num1%和%num2%最大公约数为:
:test
set /a temp=%num1% %% %num2%
if %temp% NEQ 0 (
set /a num1=!num2!
set /a num2=!temp!
goto :test)
echo %num2%
pause>nul
[ Last edited by youxi01 on 2007-1-13 at 02:27 AM ]
a=inputbox("请输入两个数用空格分开:")
h=split(a," ")
min=h(0)
if h(0)>h(1) then min=h(1)
for i=1 to min
if h(0) mod i=0 and h(1) mod i=0 then s=i
next
msgbox h(0)&"和"&h(1)&"的最大公约数是:"&s