|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
各位的代码都很精彩,比起我的 sort 方案来,高明了很多,给各位加分!
Everyone's code is very wonderful. Compared with my sort scheme, it is much more sophisticated. I will give you all points!
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-11-30 02:49 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
|
2006-11-30 02:53 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
redtek的利用shift移位,set .的按顺序显示特性
增加出现次数最多的显示^_^
@echo off
setlocal EnableDelayedExpansion
set str=adadfdfseffserfefsefseetsdg
:loop
set str$=%str$% %str:~0,1% && set str=%str:~1%
if not "%str%" == "" goto loop
call :start %str$%
set .
echo 出现次数最多的:%max%=%maxN%
pause
exit
:start
if == ( goto :eof ) else ( set /a .%1+=1 )
if !.%1! GTR !maxN! set maxN=!.%1!&&set max=.%1
shift
goto :start
修改了BUG
Last edited by zxcv on 2006-11-29 at 08:27 PM ]
Redtek's use of shift shifting and the sequential display feature of set .
Increase the display of the most frequent occurrence ^_^
@echo off
setlocal EnableDelayedExpansion
set str=adadfdfseffserfefsefseetsdg
:loop
set str$=%str$% %str:~0,1% && set str=%str:~1%
if not "%str%" == "" goto loop
call :start %str$%
set .
echo The most frequent occurrence: %max%=%maxN%
pause
exit
:start
if == ( goto :eof ) else ( set /a .%1+=1 )
if !.%1! GTR !maxN! set maxN=!.%1!&&set max=.%1
shift
goto :start
Bug fixed
Last edited by zxcv on 2006-11-29 at 08:27 PM ]
|
|
2006-11-30 02:58 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
namejm兄17楼的方案 “做一个文本中关于内容统计的批处理” 正在欣赏,里面的代码真是有意思,太精彩了~~:)))
回zxcv兄:我15楼代码没有做出现次数最多的那部分是因为我不会做(偷偷的说~)
真是精彩~~跟namejm、zxcv兄学习了~:)))
Brother namejm on floor 17's plan "Make a batch script for content statistics in text" is being appreciated. The code inside is really interesting and wonderful ~~ : ) ) )
In response to Brother zxcv: The reason the code on my floor 15 didn't include the part for the most frequent occurrence is because I didn't know how to do it (whispering ~)
Really wonderful ~~ Learned from Brothers namejm and zxcv ~ : ) ) )
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-11-30 03:14 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
I'm learning on the fly 
All are good examples of learning  good role models 
|
|
2006-11-30 03:18 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
厉害, 各位加油^_^
Great, everyone keep it up^_^
|

业精于勤而荒于嬉,形成于思而毁于随。 |
|
2006-11-30 03:33 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
if !.%1! GTR !maxN! set maxN=!.%1! && set max=.%1
if %%j GTR !l! set l=%%j & set m=%%i
namejm和zxcv兄的这句有意思~~
找出最大的一个数,如果取到的值大于 “存储最大值的变量” ,则说明取到的数更大,则让它来代替原 “存储最大值的变量” 内,
当数据全“走”过一遍以后,“存储最大值的变量” 内的值自然是最大的值~:)
欣赏加狂顶!!!
又学到很多东东,交流碰撞出很多灵感~~
if !.%1! GTR !maxN! set maxN=!.%1! && set max=.%1
if %%j GTR !l! set l=%%j & set m=%%i
The sentence from user namejm and zxcv is interesting~~
Find the largest number. If the value obtained is greater than the "variable storing the maximum value", it means the obtained number is larger, so it should replace the original value in the "variable storing the maximum value". After all the data has been "gone through", the value in the "variable storing the maximum value" will naturally be the largest value~:)
Appreciate and strongly support!!!
Learned a lot more, and communication has sparked many inspirations~
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-11-30 03:48 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
刚才测试了一下18楼的代码,在18楼代码的基础上,我增加了str变量的值,把它设置为:set str=adadfdfseffserfefsefseetsdgdsfjkljdsklfjdsfdsgdsafdsaf,然后运行批处理,结果:
.a=4
.d=10
.e=6
.f=12
.g=2
.j=3
.k=2
.l=2
.r=1
.s=11
.t=1
出现次数最多的:.f=9
请按任意键继续. . .
Just tested the code on floor 18. Based on the code on floor 18, I increased the value of the str variable and set it to: set str=adadfdfseffserfefsefseetsdgdsfjkljdsklfjdsfdsgdsafdsaf, then ran the batch file, and the result was:
.a=4
.d=10
.e=6
.f=9
.g=2
.j=3
.k=2
.l=2
.r=1
.s=11
.t=1
The most frequent occurrence: .f=9
Press any key to continue. . .
|
|
2006-11-30 04:13 |
|
|
无奈何
荣誉版主
      
积分 1338
发帖 356
注册 2005-7-15
状态 离线
|
『第 24 楼』:
使用 LLM 解释/回答一下
后面的越来越精彩了,这样的交流大家收获都不少,学习的还快,还有趣味。
建议以后大家多发现一些这样的问题,要求不要太难,重在参与。
大家讨论一下以后可不可以每期增加一些名誉性的奖项,比如:
代码最短
速度最快
稳定性最强
创意最好
还有一种谁都看不明白,但是能完成功能。
从这几个角度充分发挥大家的发散思维。不过,类似这样的名字怎么取...
The latter ones are getting more and more exciting. Everyone gains a lot from such exchanges, learns quickly and it's also interesting.
It is suggested that everyone find more such problems in the future. The requirements should not be too difficult, focusing on participation.
Let's discuss whether we can add some honorary awards in each session in the future, such as:
Shortest code
Fastest speed
Strongest stability
Best creativity
And another type that no one can understand but can complete the function.
Give full play to everyone's divergent thinking from these perspectives. However, how to name such things...
|

☆开始\运行 (WIN+R)☆
%ComSpec% /cset,=何奈无── 。何奈可无是原,事奈无做人奈无&for,/l,%i,in,(22,-1,0)do,@call,set/p= %,:~%i,1%<nul&ping/n 1 127.1>nul
|
|
2006-11-30 04:31 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 25 楼』:
使用 LLM 解释/回答一下
还有一种谁都看不明白,但是能完成功能
呵呵,这个非无奈何斑竹你魔术了
There is another kind that no one can understand clearly but can complete the function. Hehe, this non-willing to be helpless moderator, you did magic.
|
|
2006-11-30 04:49 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 26 楼』:
使用 LLM 解释/回答一下
那版主的名字就是 “空前绝后” 这名字棒吧~~
Then the moderator's name is "Unprecedented"~ Isn't this name great?
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-11-30 05:08 |
|
|
tao0610
高级用户
    朦胧的世界
积分 579
发帖 218
注册 2006-10-24
状态 离线
|
『第 27 楼』:
使用 LLM 解释/回答一下
MS出现次数最多的结果都不太对,问题出在那里?
The results with the most occurrences of MS are not quite right. Where is the problem?
|

认识自己,降伏自己,改变自己,才能改变别人! |
|
2006-11-30 05:20 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
 『第 28 楼』:
使用 LLM 解释/回答一下
也贴一段不成熟的代码,统计各字符出现的次数:
思路:先用“函数”test取得变量str的长度,保存为OSlen;
然后取得变量的第一个字符,保存为str0,然后将变量str中的str0全部替换为空,再获取str的长度,保存为%num%,那么第一个出现的字符为:%str0%,长度为:%OSlen%-%num%,依次类推.....
@echo off
setlocal EnableDelayedExpansion
set str=adadfdfseffserfefsefseetsdg
call :test %str%
for /l %%i in (0 1 100) do (
set /a OSlen=!num!
set str%%i=!str:~0,1!
call :test1 !str! !str%%i! %%i)
:exit
pause>nul
exit
:test
set /a num=0
set var=%1
for /l %%i in (1 1 100) do (
set var_=!var:~%%i,1!
if "!var_!"=="" set /a num=%%i &&goto :eof)
goto :eof
:test1
set var=%1
set var_=%2
set num_=%3
set str=!var:%var_%=!
if "%str%"=="" goto :exit
call :test %str%
set /a len%num_%=!OSlen!-!num!
echo 字符 %2 出现的次数 !len%num_%!
Last edited by youxi01 on 2006-11-30 at 06:47 AM ]
Also post an immature piece of code to count the number of occurrences of each character:
Idea: First use the "function" test to get the length of variable str and save it as OSlen; then get the first character of variable str and save it as str0, then replace all str0 in variable str with empty, then get the length of str and save it as %num%, then the first character that appears is: %str0%, and the length is: %OSlen%-%num%, and so on.....
@echo off
setlocal EnableDelayedExpansion
set str=adadfdfseffserfefsefseetsdg
call :test %str%
for /l %%i in (0 1 100) do (
set /a OSlen=!num!
set str%%i=!str:~0,1!
call :test1 !str! !str%%i! %%i)
:exit
pause>nul
exit
:test
set /a num=0
set var=%1
for /l %%i in (1 1 100) do (
set var_=!var:~%%i,1!
if "!var_!"=="" set /a num=%%i &&goto :eof)
goto :eof
:test1
set var=%1
set var_=%2
set num_=%3
set str=!var:%var_%=!
if "%str%"=="" goto :exit
call :test %str%
set /a len%num_%=!OSlen!-!num!
echo Character %2 appears !len%num_%! times
Last edited by youxi01 on 2006-11-30 at 06:47 AM ]
|
|
2006-11-30 05:23 |
|
|
tao0610
高级用户
    朦胧的世界
积分 579
发帖 218
注册 2006-10-24
状态 离线
|
 『第 29 楼』:
使用 LLM 解释/回答一下
用for /l 的我也贴一个!
@echo off&setlocal enabledelayedexpansion
set str=adadfdfseffserfefsefseetsdgdsfjkljdsklfjdsfdsgdsafdsaf
for /l %%i in (0,1,100) do (
if "!str:~%%i,1!"=="" goto end
call :define !str:~%%i,1!
set/a !str:~%%i,1!+=1
)
:end
for /l %%x in (1,1,%num%) do (
call set exchang=%%!%%x!%%
call echo !%%x!--%%!%%x!%%个
if !exchang! gtr !max! call set max=%%!%%x!%%&set maxstr=!%%x!)
echo.&echo.出现次数最多的是%maxstr%=%max%次
pause>nul&goto :eof
:define
if not defined %1 set/a num+=1&&set !num!=%1
I also post one using for /l!
@echo off&setlocal enabledelayedexpansion
set str=adadfdfseffserfefsefseetsdgdsfjkljdsklfjdsfdsgdsafdsaf
for /l %%i in (0,1,100) do (
if "!str:~%%i,1!"=="" goto end
call :define !str:~%%i,1!
set/a !str:~%%i,1!+=1
)
:end
for /l %%x in (1,1,%num%) do (
call set exchang=%%!%%x!%%
call echo !%%x!--%%!%%x!%%个
if !exchang! gtr !max! call set max=%%!%%x!%%&set maxstr=!%%x!)
echo.&echo.出现次数最多的是%maxstr%=%max%次
pause>nul&goto :eof
:define
if not defined %1 set/a num+=1&&set !num!=%1
|

认识自己,降伏自己,改变自己,才能改变别人! |
|
2006-11-30 05:29 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
 『第 30 楼』:
使用 LLM 解释/回答一下
欣赏15、18楼的代码,学习了!对以上代码稍做了改动,灵魂不变!
@echo off
setlocal EnableDelayedExpansion
set str=adadfdfseffserfefsefseetsdg
for /l %%i in (0 1 100) do (
if "!str:~%%i,1!"=="" goto :exit
set /a .!str:~%%i,1!+=1)
:exit
set.
for /f "delims== tokens=1,2" %%i in ('set.') do (
if %%j GTR !maxl! set /a maxl=%%j && set max=%%i)
echo 出现最多的是 %max:.=% 字符,共 %maxl% 个
pause
Appreciate the code on floors 15 and 18, learned it! Made a little change to the above code, but the essence remains!
@echo off
setlocal EnableDelayedExpansion
set str=adadfdfseffserfefsefseetsdg
for /l %%i in (0 1 100) do (
if "!str:~%%i,1!"=="" goto :exit
set /a .!str:~%%i,1!+=1)
:exit
set.
for /f "delims== tokens=1,2" %%i in ('set.') do (
if %%j GTR !maxl! set /a maxl=%%j && set max=%%i)
echo The most frequent is %max:.=% character, total %maxl% times
pause
|
|
2006-11-30 06:10 |
|