为什么两段代码运行结果会不一样
==============代码1================- setlocal enabledelayedexpansion
- set /p a=输入整数大于0:
- set /p b=输入整数小于a:
- set /a c=a/b
- set /a d=a-c*b
- set /a m=0,n=1
-
- for /l %%i in ( 1 1 %a% ) do (
- echo %%i >>abc-!n!.txt
- set /a m=m+1
- if !n! leq %d% (
- if !m! geq %c%+1 (
- set m=0
- set /a n=n+1)
- ) else (
- if !m! geq %c% (set m=0
- if !n! lss %b% (set /a n=n+1)
- )
- )
- )
- pause
复制代码 ==============代码2================- setlocal enabledelayedexpansion
- set /p a=输入整数大于0:
- set /p b=输入整数小于a:
- set /a c=a/b
- set /a d=a-c*b
- set /a m=0,n=1
-
- for /l %%i in ( 1 1 %a% ) do (
- echo %%i >>abc-!n!.txt
- set /a m=m+1
- if !n! leq %d% (
- if !m! [color=Red]equ[/color] %c%+1 (
- set m=0
- set /a n=n+1)
- ) else (
- if !m! [color=Red]equ[/color] %c% (set m=0
- if !n! lss %b% (set /a n=n+1)
- )
- )
- )
- pause
复制代码
|