以本人的理解,此题还是有点问题,有些数是不能分的,如4,8,16本人代码如下,请大家指证:- @echo off&setlocal enabledelayedexpansion
- cd.>temp.txt
- set /p n=请输入要折分的数字:
- set /a x=n,y=n%%2
- for /l %%a in (1,1,10) do set /a x=(x+n/x)/2
- set /a x+=1,y=3-y
- for /l %%a in (%y%,1,%x%) do (
- set /a a=%%a%%2,b=%%a/2,c=n%%%%a,d=n/%%a,min=1,max=0
- if !a! neq 0 (
- if !c! equ 0 set /a min=d-b,max=d+b
- ) else (
- if !c! neq 0 (
- set /a e=2*n,e=e%%%%a
- if !e! equ 0 set /a min=d-b+1,max=d+b
- )
- )
- for /l %%b in (!min!,1,!max!) do set /p=%%b <nul>>temp.txt
- if !max! neq 0 set flag=a&echo.>>temp.txt
- )
- if not defined flag echo 此数不可分>temp.txt
- start temp.txt
复制代码
[ 本帖最后由 batman 于 2009-8-29 21:21 编辑 ] |