下面这个是手动的,自己输入"7877" 和"6766" 试试吧!还可以输入类似 0001 0101 之类的。- @echo off & setlocal enabledelayedexpansion
- :begin
- set n=1
- set /p res=请输入一个四位数,每位数字是0~9,但不能完全相同:
- if "!res:%res:~,1%=!"=="" echo %res% 是全相同数&pause&goto begin
- :lp
- 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 a=%str%-(1%str1%-10000)
- set b=000%a%
- set res=%b:~-4%
- echo %str%-%str1%=%res%
- del tmp.txt
- if %res% neq 6174 set /a n+=1&goto lp
- echo 共运行了%n%次
- pause & cls & goto begin
复制代码
|