- @echo off&title 数字黑洞
- ::code by garyng@vista sp2
- :main
- setlocal enabledelayedexpansion
- if exist re.txt del /q re.txt
- if exist re1.txt del /q re1.txt
- if exist re2.txt del /q re2.txt
- if exist re3.txt del /q re3.txt
- cls
- set a=&set num=1&set var=
- set /p "var=请输入小于2147483647数字:"
- echo %var%|findstr /b "[0-9]">nul||goto main
- if "!var:~0,1!" equ "0" for /f "delims=0 tokens=*" %%c in ('echo !var!') do (set var=%%c&cls)
- if !var! GEQ 2147483647 echo 数目太大啦~小于2147483647&ping -n 3 127.1>nul 2>nul&goto main
- if !var! equ 0 echo 0减0还是0~&ping -n 3 127.1>nul 2>nul&goto main
- :loop
- for /l %%a in (0,1,15) do if "!var:~%%a,1!" equ "" set a=%%a&goto leng
- :leng
- for /l %%i in (0 1 %a%) do (
- set ch=!var:~%%i,1!
- set pai%%i=!ch!
- if not "!pai%%i!"=="" set /p=!pai%%i! <nul >>re.txt
- )
- (set /p str=)<re.txt
- del /q re.txt
- if !num! equ 1 if !a! GEQ 5 echo 4位数以上的数目重复的不是一个数目,而是一个数组!!
- SETLOCAL ENABLEEXTENSIONS
- for %%b in (%str%) do (
- set str=0000000000%%b
- set .!str:~-10! !random!=%%b
- )
- for /f "tokens=2 delims==" %%b in ('set .') do set/p=%%b<nul>>re1.txt
- endlocal
- (set /p re1=)<re1.txt
- del /q re1.txt
- set /a a-=1
- for /l %%a in (%a% -1 0) do call set /p=%%re1:~%%a,1%%<nul>>re2.txt
- (set /p re2=)<re2.txt
- del /q re2.txt
- if "!re1:~0,1!" equ "0" for /f "delims=0 tokens=*" %%d in ('echo !re1!') do set re1=%%d
- if /i "%re1%" GTR "%re2%" (set /a minus=!re1!-!re2!) else (set /a minus=!re2!-!re1!)
- if !minus! equ 0 echo 变0了~还减啥啊?&echo 按任意键重来...&pause>nul&endlocal&goto main
- echo !minus!>>re3.txt
- set /a line=!num!-1
- (for /l %%e in (1 1 %line%) do set /p re3=)<re3.txt
- if "!minus!" equ "!re3!" (goto repeated) else (echo 第!num!次:!minus!)
- set var=!minus!&set /a num+=1&set a=&set re1=&set re2=&set str=&set minus=&set ch=
- goto loop
- :repeated
- echo ----------&echo 第!num!次:这次的数字!minus!与上次相同~&echo 如果继续下去的话,会一直是同样的数目~&echo 这数字已经“掉进”黑洞里啦~&echo 按任意键重来...&pause>nul&endlocal&goto main
复制代码 很久以前写的。 |