ImageVerifierCode 换一换
格式:DOCX , 页数:17 ,大小:19.80KB ,
资源ID:4079760      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/4079760.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(批处理开平方.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

批处理开平方.docx

1、批处理开平方批处理如何开平方批处理开平方,网上已有很多方法。但都存在一个问题:精确位数低,还有计算错误。甚至有的计算还很慢。本批处理程序算法能在较短时间内计算到较大的位数,实现了批处理开方的更高程度。以后会有更新:1.对算法进行优化:四百位以内平均十秒一位。 而非像现在需要十分钟。2.扩大被开方数范围:支持小数,且被开方数 数字个数(含小数点)从10扩大到2147483640。(注:未更新前仅支持1627396281及以内,刚好10位数)敬请期待!另外,不知道如何将以下代码做成bat程序的请XX一下:如何制作bat注意,部分计算器对最后一位进行了四舍五入,本程序可能会与计算器的最后一位相差1。

2、这不是本程序的错误。不相信本程序计算能力的的计算根号2,XX搜索:根号2 1000位 即可查到,可与本程序计算结果对比。代码中 大号 红色 加粗 加下划线 字仅为显示进度,为缩短计算时间可删除。可节省不少时间。代码如下:(注意别复制到结尾,代码部分包含两个程序)echo offtitle 计算整数平方根的值color f0PUSHD %dp0cd /d %dp0setlocal enabledelayedexpansionclsecho -echo 计算整数平方根的值echo -:startecho.&echo 请输入被开方数(仅限整数),然后按回车键:echo (被开方数最高为1627396

3、281,超出范围,会计算出错)set number=set /p number=goto next:nextclsif %number%= goto startset /a temp=%number%+0if not %temp%=%number% goto error_aif not %number% geq 0 goto error_bif %number% geq 1627396282 goto error_cgoto then:thenclsecho.&echo 请输入精确位数,然后按回车键:echo (指精确到小数点后第几位)echo (该程序不会对最后一位进行四舍五入)echo (

4、精确位数最高为238609294,超出范围,会计算出错)echo (对于结果为整数的,程序会舍去小数部分)set bit=set /p bit=goto other:otherclsif %bit%= goto thenset /a temp=%bit%+0if not %bit%=%temp% goto error_dif not %bit% geq 0 goto error_dif %bit% geq 238609295 goto error_eset start=yesgoto main:error_aclscolor fcecho 错误:输入的被开方数不是整数,请重新输入!echo 其

5、绝对值不得超过批处理支持的最大值(2147483647)!echo 请不要在整数前加上正号(+)或多余的零!echo.&echo 按任意键继续:&pausenulcolor f0clsgoto start:error_bclscolor fcecho 错误:平方根中被开方数不能小于0,请重新输入!echo.&echo 按任意键继续:&pausenulcolor f0clsgoto start:error_cclscolor fcecho 错误:被开方数不能大于1627396281,请重新输入!echo.&echo 按任意键继续:&pausenulcolor f0clsgoto start:er

6、ror_dclscolor fcecho 错误:输入的精确位数不是正整数,请重新输入!echo 其绝对值不得超过批处理支持的最大值(2147483647)!echo 请不要在整数前加上正号(+)或多余的零!echo.&echo 按任意键继续:&pausenulcolor f0clsgoto then:error_eclscolor fcecho 错误:精确位数不能大于238609294,请重新输入!echo.&echo 按任意键继续:&pausenulcolor f0clsgoto then:mainclsecho.&echo 已经开始计算。echo 每计算一位,都会对结果更新!echo 越往

7、后计算,结果显示越慢!请耐心等待本程序计算完成。echo.&echo 被开方数:%number%if not %start%=yes (set /a num+=1set /a tga=!num!-%allbit%-1set /a temp=!tga!%4if not !tga!=1 (if !temp!=1 (set nun=%nun% %main:-1%) else (set nun=%nun%main:-1%) else (set nun=%nun%main:-1%)set /a temp=%tga%+1if !temp!=%bit% goto endecho.&echo 计算结果(未对其

8、结果进行四舍五入):echo.&echo %nun%goto js) else (echo.&echo 请稍候goto temp):tempset u=0set tga=0call :stringlenth %number% numset /a allbit=(%num%+1)/2set num=%allbit%set tgb=%num%set /a num+=1for /l %i in (0 1 %num%) do set js%i=0if %allbit%=1 (set kfmain=js1call :kfmain) else (for /l %i in (%tgb% -1 1) do (

9、set u=0set kfmain=js%icall :kfmainset js%i=!temp!)set temp=for /l %i in (%tgb% -1 1) do (set temp=!temp!js%i!)set all=%temp%set /a temp=%all%*%all%if %temp%=%number% (set bit=0set nun=%all%goto end)if %bit%=0 (set nun=%all%goto end)set main=%all%.set nun=%all%.set start=nogoto js:jsset nmn=%main:.=%

10、set /a tgb=%num%-1set kfmain=js0if %tgb%=1 (set js1=%nmn%) else (for /l %i in (%tgb% -1 1) do (set temp=!nmn:-%i!set js%i=!temp:0,1!)set js%num%=0set u=0call :kfmainset main=%main%temp%goto main:endclsecho.&echo 计算完毕!echo.&echo 被开方数:%number%echo.&echo 计算结果(未对其结果进行四舍五入):echo !nun!echo.&echo 按任意键继续:&p

11、ausenulclsecho 请选择接下来的操作。echo -echo 0:退出echo 1:返回重新计算echo 2:将结果保存至桌面。echo -set choice=set /p choice=请输入操作序号,然后按回车键:if %choice%=0 exit /bif %choice%=1 (clsgoto start)if %choice%=2 goto exit_onegoto end:exit_oneif %bit%=0 (set temp=(保留整数)) else (set temp=(精确到小数点后第%bit%位))cd /d %UserProfile%desktopif e

12、xist %number%的平方根的结果%temp%.txt (takeown %number%的平方根的结果%temp%.txtdel /f /s /q %number%的平方根的结果%temp%.txt)echo %number%的平方根的结果:%number%的平方根的结果%temp%.txtecho %temp%:%number%的平方根的结果%temp%.txtecho (未对其结果进行四舍五入):%number%的平方根的结果%temp%.txtecho %nun%number%的平方根的结果%temp%.txtgoto exit:exitclsecho.&echo 保存完毕。ec

13、ho 请选择接下来的操作。echo -echo 0:退出echo 1:返回重新计算echo 2:打开保存到的文件并退出echo -set choice=set /p choice=请输入操作序号,然后按回车键:if %choice%=0 exit /bif %choice%=1 (clsgoto start)if %choice%=2 (start /d %windir% notepad.exe %UserProfile%desktop%number%的平方根的结果%temp%.txtexit /b)goto exit:kfmainset /a u+=1if %er%=2m (set %kfm

14、ain%=1goto jsmain)if %er%=5m (set %kfmain%=2goto jsmain)if %er%=4m (set %kfmain%=3goto jsmain)if %er%=2l (set %kfmain%=4goto jsmain)if %u%=1 (set %kfmain%=5goto jsmain)if %er%=7m (set %kfmain%=6goto jsmain)if %er%=5l (set %kfmain%=7goto jsmain)if %er%=9m (set %kfmain%=8goto jsmain)if %er%=7l (set %k

15、fmain%=9goto jsmain)if %er%=1m set temp=0if %er%=1l set temp=1if %er%=3m set temp=2if %er%=3l set temp=3if %er%=4l set temp=4if %er%=6m set temp=5if %er%=6l set temp=6if %er%=8m set temp=7if %er%=8l set temp=8if %er%=9l set temp=9goto :eof:jsmainset tgc=0set /a tgd=%num%*2-1for /l %i in (%tgd% -1 0)

16、 do set dg%i=0for /l %i in (0 1 %tgb%) do (for /l %r in (0 1 %num%) do (set /a i=%i+%rset /a temp=!js%i!*!js%r!+!tgc!set /a dg!i!+=!temp!%10set /a tgc=!temp!/10)set tgc=0if %tga% geq 50 (if %tga% geq 100 (set /p=nulset /p=总进度:%u%(最少3,最多4),副进度:%i(共%tgb%) nul) else (set /p=nulset /p=总进度:%u%(最少3,最多4) n

17、ulclsgoto start)if not %bit% geq 0 (clscolor fcecho 错误:输入的精确位数不是正整数,请重新输入!echo.&echo 按任意键继续:&pausenulclsgoto start)if not %bit% leq 238609294 (clscolor fcecho 错误:输入的精确位数不能大于238609294,请重新输入!echo.&echo 按任意键继续:&pausenulclsgoto start)goto start_ct:start_ct:可在下面保存进度:例:已算出结果为1.4142 1356:则可改为set nun=1.4142

18、 1356。注意小数点后四位一个英文状态下的空格,:但末尾不得有空格。(例:正确:1.4142,错误:1.4142 ):清除进度,改为set nun=1.。1.不能丢!set nun=1.4142 1356 2373 0950 4880 1688 7242 0969 8078 5696 7187 5376 9480 7317 6679 7379 9073 2478 4621 0703 8850 3875 3432 7641 5727 3501 3846 2309 1229 7024 9248 3605 5850 7372 1264 4121 4970 9993 5831 4132 2266 5

19、927 5055 9275 5799 9505 0115 2782 0605 7147 0109 5599 7160 5970 2745 3459 6862 0147 2851 7418 6408 8919 8609 5523 2923 0484 3087 1432 1450 8397 6260 3627 9952 5140 7989 6872 5339 6546 3318 0882 9640 6206 1525 8352 3950 5474 5750 2877 5996 1729 8355 7522 0337 5318 5701 1354 3746 0340 8498 8471 6038 6

20、899 9706 9900 4815 0305 4402 7790 3164 5424 7823 0684 9293 6918 6set num=%nun: =%call :stringlenth %num% numberset /a number=%number%-1set c=1goto main:mainclsset /a number=%number%+1:显示优化,四位一空格。set /a tga=%number%-2if %c%=0 (set a=%num:-1%set /a b=!tga!%4if not %tga%=1 (if %b%=0 set a= !a!)set nun=

21、%nun%!a!) else (set c=0set /a b=!tga!%4)echo.&echo 已经开始计算。echo 在没有看到结尾信息时,请勿关闭本窗口!echo 每计算一位,都会对结果更新!该程序不会对最后一位进行四舍五入。echo 越往后计算,结果显示越慢!请耐心等待本程序计算完成。echo.&echo 计算结果:echo %nun%echo.set /a tga=%number%-2if %tga% geq %bit% goto exitoneif %tga%=0 goto jsksif %tga%=1 (set a1=%num:-1%goto jsks)for /l %i i

22、n (%tga%,-1,1) do (set aaqq=!num:-%i!set a%i=!aaqq:0,1!)goto jsks:jsksset /a tgz=%number%-1set a%number%=0: (下)原为set a%tgz%=!num:0,1!,其结果为1set a%tgz%=1set mainmain=00set z=0goto kfmain:kfmainset /a z+=1if %mainmain%=2m (set a0=1call :jsmaingoto kfmain)if %mainmain%=5m (set a0=2call :jsmaingoto kfmai

23、n)if %mainmain%=4m (set a0=3call :jsmaingoto kfmain)if %mainmain%=2l (set a0=4call :jsmaingoto kfmain)if %mainmain%=00 (set a0=5call :jsmaingoto kfmain)if %mainmain%=7m (set a0=6call :jsmaingoto kfmain)if %mainmain%=5l (set a0=7call :jsmaingoto kfmain)if %mainmain%=9m (set a0=8call :jsmaingoto kfmain)if %mainmain%=7l (set a0=9call :jsmaingoto kfmain)if %mainmain%=1m set tempab=0if %mainmain%=1l set tempab=1if %mainmain%=3m set tempab=2if %mainmain%=3l set tempab=3if %mainmain%=4l set tempab=4if %mainmain%=6m set tempab=5if %mainmain%=6l set te

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1