本帖最后由 keiamy 于 2012-3-14 10:54 编辑
在无意中发现,原来7877,6766等一系列数字会报错,看来数字黑洞真的有个洞了....
本人是小白,代码是参考3楼的- @echo off&setlocal enabledelayedexpansion
- :begin
- cls
- set /a res=%random%%%8999+1001
- echo 初始数是 %res%
- set n=1
- :lp
- if "!res:%res:~,1%=!"=="" echo %res% 是全相同数&pause&goto begin
- set "str="&set "str1="
- for /l %%i in (0 1 3) do echo !res:~%%i,1!>>tmp.txt
- for /f %%i in ('sort tmp.txt') do set "str=%%i!str!"&set "str1=!str1!%%i"
- set /a res=str-(1%str1%-10000)
- echo %str%-%str1%=%res%
- del tmp.txt
- if %res% neq 6174 set /a n+=1&goto lp
- echo 共运行了 %n% 次
- pause&goto begin
复制代码
|