|
0401
中级用户
   带走
积分 435
发帖 88
注册 2005-9-24
状态 离线
|
|
2007-1-7 06:23 |
|
|
0401
中级用户
   带走
积分 435
发帖 88
注册 2005-9-24
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
==已被删除==
Last edited by 0401 on 2007-1-25 at 09:19 AM ]
==Deleted==
Last edited by 0401 on 2007-1-25 at 09:19 AM ]
|
|
2007-1-7 06:24 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
|
2007-1-7 08:46 |
|
|
0401
中级用户
   带走
积分 435
发帖 88
注册 2005-9-24
状态 离线
|
 『第 4 楼』:
使用 LLM 解释/回答一下
Originally posted by electronixtar at 2007-1-7 08:46:
楼主强人
我是菜鸟,而且害羞。
用同一种方法再贴一个十进制转二进制的。
@echo off
setlocal enabledelayedexpansion
set/p scanf=能正确处理的最大数为,请输入需要转换的十进制数:
if not defined scanf exit/b
set dec=%scanf%
call :d2b
echo %dec% 的二进制为:%bin%
pause>nul
exit/b
:d2b
set a=1
for /l %%i in (1,1,31) do (
set/a t=%scanf%"&"!a!
set/a a*=2
if !t! equ 0 (set bin=0!bin!) else (set bin=1!bin!)
)
if %bin% equ 0 set bin=0 & goto :eof
:cut0
if %bin:~0,1% equ 0 set bin=%bin:~1%&goto :cut0
Originally posted by electronixtar at 2007-1-7 08:46:
The building owner is a strong person
I'm a noob, and I'm shy.
Post another decimal to binary conversion using the same method.
@echo off
setlocal enabledelayedexpansion
set/p scanf=The maximum number that can be correctly processed is , please enter the decimal number to be converted:
if not defined scanf exit/b
set dec=%scanf%
call :d2b
echo The binary of %dec% is: %bin%
pause>nul
exit/b
:d2b
set a=1
for /l %%i in (1,1,31) do (
set/a t=%scanf%"&"!a!
set/a a*=2
if !t! equ 0 (set bin=0!bin!) else (set bin=1!bin!)
)
if %bin% equ 0 set bin=0 & goto :eof
:cut0
if %bin:~0,1% equ 0 set bin=%bin:~1%&goto :cut0
此帖被 +15 点积分 点击查看详情 评分人:【 lxmxn 】 | 分数: +10 | 时间:2007-1-8 04:28 | 评分人:【 ccwan 】 | 分数: +5 | 时间:2007-1-12 06:57 |
|
|
|
2007-1-7 09:24 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
|
2007-1-7 17:15 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
超级顶!欣赏~~:)
Super top! Appreciate ~~ : )
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2007-1-7 21:04 |
|
|
vlanmaster
初级用户
 
积分 100
发帖 46
注册 2006-12-19
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
用的果然爽,厉害。
It's really refreshing to use, amazing.
|
|
2007-1-12 06:55 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
的是厉害。顶了
That's really amazing. I'm supporting it.
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2007-1-12 06:57 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
0401 兄4楼的 十进制转二进制的 还可以改改的,后面的那 标签:cut0 属于多余
改为这样就好了
:d2b
set a=1
for /l %%i in (1,1,30) do (
set/a t=%scanf%"&"!a!
set/a a*=2
if !t! equ 0 (set bin=0!bin!) else (set bin=1!bin!)
if %scanf% lss !a! exit/b
)
if %bin% equ 0 set bin=0 & goto :eof
修改如下:
1: 1,1,30 因为你for /l %%i in (1,1,31) do (set/a a*=a) 就已经出错了
2: 加了一句 if %scanf% lss !a! exit/b ,因为数a 与 运算 比它大的数永远是0,既然这样还不如直接if %scanf% lss !a! exit/b结束,后面也就不去前面的 0 了
Brother 0401 on the 4th floor, the decimal to binary conversion can still be improved. The tag :cut0 at the end is redundant. It's better to be like this:
:d2b
set a=1
for /l %%i in (1,1,31) do (
set/a t=%scanf%"&"!a!
set/a a*=2
if !t! equ 0 (set bin=0!bin!) else (set bin=1!bin!)
if %scanf% lss !a! exit/b
)
if %bin% equ 0 set bin=0 & goto :eof
Modifications are as follows:
1: 1,1,30 is changed because for /l %%i in (1,1,31) do (set/a a*=a) will already have an error.
2: Added a line if %scanf% lss !a! exit/b, because the operation of number a and a larger number is always 0. Since this is the case, it's better to directly end with if %scanf% lss !a! exit/b, and then the preceding 0s won't be removed later.
|
|
2007-3-13 07:50 |
|
|
xycoordinate
中级用户
  
积分 493
发帖 228
注册 2007-2-16 来自 安徽
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
先加个"戳",不然下次用时找不到!
Add a "stamp" first, otherwise it won't be found next time!
|
|
2007-3-13 08:22 |
|
|
genteman
初级用户
 
积分 90
发帖 43
注册 2007-10-31
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
我来回复9楼
if %scanf% lss !a! exit/b
你的这段代码缺点很明显,
每做一次循环,都要判断一次,降低了程序效率
I will reply to post 9
if %scanf% lss !a! exit/b
There are obvious drawbacks in your code.
Every time the loop is executed, a judgment is made, which reduces the program efficiency
|
|
2007-11-2 12:44 |
|
|
genteman
初级用户
 
积分 90
发帖 43
注册 2007-10-31
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
还有一个问题
“ 1,1,30 因为你for /l %%i in (1,1,31) do (set/a a*=a) 就已经出错了”
这里%%i=31的时候,a=2(30),并没有错,要到%%i=32时,a=2(31),
这时才有错
所以9楼的代码才是正确的!
There is another question
"1,1,30 Because you for /l %%i in (1,1,31) do (set/a a*=a) has already gone wrong"
When %%i = 31 here, a = 2^(30), there is no mistake. It will be wrong when %%i = 32, at this time a = 2^(31)
So the code on floor 9 is correct!
|
|
2007-11-2 12:57 |
|
|
ZJHJ
高级用户
   
积分 609
发帖 374
注册 2006-8-2
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
我用取余的方法写了一个 十进制转十六进制,证实了最大极限处理确实是2147483647,即十六进制极限为7FFFFFFF,反转也同样说明了这个问题。应该说是CMD的极限。
I used the method of remainder to write a decimal to hexadecimal conversion, and confirmed that the maximum limit processing is indeed 2147483647, that is, the hexadecimal limit is 7FFFFFFF, and the reversal also illustrates this problem. It should be said to be the limit of CMD.
|
|
2010-8-10 09:03 |
|