|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
|
2006-10-12 23:50 |
|
|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
|
2006-10-13 00:02 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
比你的是要慢, 测试同样的运算你的为三十多毫秒, 我的为五十来毫秒.
你的代码为小数整数一起运算, 在判断上走了捷径, 我当时编写的初忠是完全模拟人工计算. 因此代码也是最原始的计算方式.
我那段代码中使用的变量更多, 运算更为复杂,这也是影响速度的原因之一. 算法是程序的灵魂, 解决同样的问题效率都会不一样. 由于时间关系, 代码的优化已及更新稍候进行...
Last edited by pengfei on 2006-10-13 at 01:18 ]
Yours is slower. When testing the same operation, yours takes more than thirty milliseconds, and mine takes about fifty milliseconds.
Your code performs operations on decimals and integers together, taking a shortcut in judgment. My original intention when writing was to fully simulate manual calculation. Therefore, the code is the most primitive way of calculation.
The variables used in my code are more, and the operations are more complex, which is also one of the reasons affecting the speed. The algorithm is the soul of the program, and the efficiency of solving the same problem will be different. Due to time constraints, the optimization and update of the code will be carried out later...
Last edited by pengfei on 2006-10-13 at 01:18 ]
|
|
2006-10-13 00:34 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
实际以上脚本运算N位的数值范围并不现实, 原因在于环境变量存储空间是有限的...
Actually, it's not practical to calculate the numerical range of N bits with the above script, because the storage space of environment variables is limited...
|
|
2006-10-13 00:37 |
|
|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
|
2006-10-13 01:27 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
嘎嘎~~~! 关于一楼第1段代码真是不忍心修改, 虽然算法是最原始的. 但实现这样的算法用批处理的三种基本结构来完成. 自己都有点沾沾自喜, 呵呵~ 我的心血呀!!!
还是不打算修改了, 要么就用新的算法写一段新的代码.
兄弟们多多帮忙测试一下一楼第1段代码的BUG...
Gaga~~~! I really can't bear to modify the code in the first paragraph of the first floor. Although the algorithm is the most primitive. But implementing such an algorithm with the three basic structures of batch processing to complete. I am a little complacent myself, hehe~ This is my hard work!!!
Still don't plan to modify it, either write a new code with a new algorithm.
Brothers, please help test the bugs in the code of the first paragraph of the first floor...
|
|
2006-10-13 02:00 |
|
|
qasa
高级用户
   
积分 959
发帖 311
注册 2006-4-11 来自 广东-LianJiang
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
看了一下老贴,觉得这贴算法值得大家好好学习下,于是顶上来......
After reading the old post, I think the algorithm in this post is worth learning from by everyone, so I'm bumping it up......
|

κχυμγνξοθπρωψιαδλεηφβτζσ┬╀┾┳┞┯┰┱┣┲┳╂╁│├┟┭┠这是什么??这就是我的人生 |
|
2007-2-23 06:20 |
|
|
breakme
新手上路

积分 5
发帖 6
注册 2008-11-2
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
原来你们早就处理好此事,我还想自己也写个计算器,不过,我想把你们的全部合并,做一个混合运算的calc
有无支持平方根的批处理??
So you guys have already handled this matter. I also wanted to write a calculator myself, but I want to combine all of yours to make a mixed-operation calc. Is there any batch script that supports square roots?
|
|
2008-11-4 01:04 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 24 楼』:
Re 23楼
使用 LLM 解释/回答一下
多搜索就有了
@echo off
set a=2
set/p p=请输入需要开平方的数字(0~89999999之间)
set/p w=请输入精确到小数点后几位(9以内)
:lp
set /a a=(p/a+a)/2,n=a*a,r=a,y=p-n
if %n% lss 0 goto lp
if %n% gtr %p% goto lp
if %n% equ %p% goto ok
if "%w%"=="" goto ok
set/a m=10,x=r*20,y*=100,b+=1
:lp1
set/a m-=1,s=(x+m)*m
if %s% gtr %y% goto lp1
if %w% neq 0 set/a y-=s,r=r*10+m,t=t*10+m,m=10,x=r*20,y*=100,w-=1&goto lp1
:ok
if not "%t%" == "" set a=%a%.%t%
echo %p%开平方结果: %a%
pause>nul
Search more and you'll have it
@echo off
set a=2
set/p p=Please enter the number for square root (between 0~89999999)
set/p w=Please enter the number of decimal places to be precise (within 9)
:lp
set /a a=(p/a+a)/2,n=a*a,r=a,y=p-n
if %n% lss 0 goto lp
if %n% gtr %p% goto lp
if %n% equ %p% goto ok
if "%w%"=="" goto ok
set/a m=10,x=r*20,y*=100,b+=1
:lp1
set/a m-=1,s=(x+m)*m
if %s% gtr %y% goto lp1
if %w% neq 0 set/a y-=s,r=r*10+m,t=t*10+m,m=10,x=r*20,y*=100,w-=1&goto lp1
:ok
if not "%t%" == "" set a=%a%.%t%
echo The square root result of %p%: %a%
pause>nul
|

 |
|
2008-11-4 01:32 |
|