试试这个:
@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 ]