- @echo off
- setlocal enabledelayedexpansion
-
- :input
- set /p input=Please input a number:
- if .%input%==.0 goto exit
- set /a n=input
-
- if %n% lss 1 (
- echo Out of range!!
- goto input
- )
- if %n% gtr 999999999 (
- echo Out of range!!
- goto input
- )
- set /p p=%n%=<nul
- set i=2
-
- call:sqrt %n%
-
- :start
- ::echo .%sqrtn%.&pause>nul
- if %i% gtr %sqrtn% goto end
- set /a t=%n%%%%i%
-
- if .%t%==.0 (
- set /p "p=%i%"<nul
- set /a n/=%i%
- if not .!n!==.1 set /p "p=*"<nul
- call:sqrt !n!
- ) else (
- set /a i=%i%+1
- )
- goto start
-
- :end
- set /p "p=%n%"<nul
- echo.
- set input=
- goto input
-
- ::=============runing sqrt=================================
- :sqrt
- set type=%1
- set/a xn=type
- set/a times=1
- if %type% geq 99 set/a times=2
- if %type% geq 9999 set/a times=3
- if %type% geq 999999 set/a times=4
- if %type% geq 99999999 set/a times=5
-
- for /l %%a in (1,1,4) do (
- set/a yn=!xn!*100
- set/a zn=!yn!/100
- if not !yn! lss 0 (
- if !xn!==!zn! (
- set/a xn=!yn!
- )
- )
- )
-
- set/a sn=xn
- set sqn=1
- for /l %%a in (1,1,20) do (
- set/a sqn=sn/sqn+sqn
- set/a sqn=sqn/2
- )
-
- ::echo.
- ::echo √%type% ≈ !sqn:~0,%times%!.!sqn:~%times%!
- set sqrtn=!sqn:~0,%times%!
- goto :eof
- ::=============runing sqrt=================================
-
- :exit
复制代码
|