|
moniuming
银牌会员
     永远的菜鸟
积分 1335
发帖 574
注册 2007-11-27 来自 广西
状态 离线
|
 『第 16 楼』:
不为分数,给新人提供一个参考
使用 LLM 解释/回答一下
@echo off
Setlocal Enabledelayedexpansion
set "var1=a b c d e f g h i j k l m n o p q r s t u v w x y z"
for /l %%a in (1 1 26) do (set "var2=!var2!%%a ")
for %%a in (%var1%) do (set /a "nn+=1"&set "!nn!=%%a"&set "%%a=!nn!")
echo %var1%&echo %var2%&echo.
:lp
set /a "bt=%random%%%26+1","aa=%random%%%2+1"
for /f "tokens=%bt%" %%a in ("!var%aa%!") do (
if defined .%%a goto :lp
if defined .!%%a! goto :lp
set "ech=!ech! %%a"
set ".%%a=ok"&set ".!%%a!=ok"
)
set /a mm+=1
if %mm% lss 10 goto :lp
echo %ech%
for %%a in (%var1%) do (set ".%%a="&set ".!%%a!=")
set "mm=0"&set "ech="
pause>nul&goto :lp
Last edited by moniuming on 2008-8-25 at 02:33 PM ]
@echo off
Setlocal Enabledelayedexpansion
set "var1=a b c d e f g h i j k l m n o p q r s t u v w x y z"
for /l %%a in (1 1 26) do (set "var2=!var2!%%a ")
for %%a in (%var1%) do (set /a "nn+=1"&set "!nn!=%%a"&set "%%a=!nn!")
echo %var1%&echo %var2%&echo.
:lp
set /a "bt=%random%%%26+1","aa=%random%%%2+1"
for /f "tokens=%bt%" %%a in ("!var%aa%!") do (
if defined .%%a goto :lp
if defined .!%%a! goto :lp
set "ech=!ech! %%a"
set ".%%a=ok"&set ".!%%a!=ok"
)
set /a mm+=1
if %mm% lss 10 goto :lp
echo %ech%
for %%a in (%var1%) do (set ".%%a="&set ".!%%a!=")
set "mm=0"&set "ech="
pause>nul&goto :lp
Last edited by moniuming on 2008-8-25 at 02:33 PM ]
|
|
2008-8-25 14:31 |
|
|
BC
中级用户
  
积分 338
发帖 175
注册 2007-10-21
状态 离线
|
『第 17 楼』:
使用 LLM 解释/回答一下
谢谢前辈指点。。。
会去研究研究...
Thanks to the senior for the guidance...
Will go to study...
|

C:\
C:\Del BC |
|
2008-8-25 16:35 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
16楼的代码使用了if判断返回,因此在一定意义上存在效率问题,代码也较为复杂,但还是予以加分鼓励了。
The code on floor 16 uses if judgment and return, so it has efficiency issues to a certain extent, and the code is also more complicated, but it is still given points for encouragement.
|

批处理之家新域名:www.bathome.net |
|
2008-8-25 16:48 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
|
2008-8-25 16:58 |
|
|
BC
中级用户
  
积分 338
发帖 175
注册 2007-10-21
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
zw兄的代码真厉害...
能够写下注释吗?
能够讲解下思路是如何吗?
Last edited by BC on 2008-8-25 at 08:07 PM ]
Brother zw's code is really powerful...
Can you write comments?
Can you explain the thinking process?
Last edited by BC on 2008-8-25 at 08:07 PM ]
|

C:\
C:\Del BC |
|
2008-8-25 20:03 |
|
|
23112656
中级用户
  
积分 220
发帖 99
注册 2008-6-26
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
斑竹大哥能讲解一下
set "_!random!!random!!random!=!n!"
) else (
set "_!random!!random!!random!=%%i"
三个随机数连在一起是什么意思啊?
Can the moderator brother explain what the meaning of three random numbers connected together is in the following code:
set "_!random!!random!!random!=!n!"
) else (
set "_!random!!random!!random!=%%i"
|
|
2008-8-25 23:16 |
|
|
heheguai
初级用户
 
积分 30
发帖 18
注册 2008-5-11
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
我是新手啊,不过我做了,意思完全符合题目要求!大家看看!
@echo off&setlocal enabledelayedexpansion
set char1=abcdefghijklmnopqrstuvwxyz
set char3=1
set num=0
:loop
set /a ran=%random%%%26
set char2=!char1:~%ran%,1!
set /a num1=%ran%+1
if %num% lss 10 (
echo %char3%|find "%char2%" 1>nul
if errorlevel 1 ( set char3=%char3%%char2%&echo %num1%--%char2%&set /a num+=1&goto loop ) else ( goto loop ) )
pause
I'm a newbie, but I did it, and the meaning fully meets the requirements of the topic!
@echo off&setlocal enabledelayedexpansion
set char1=abcdefghijklmnopqrstuvwxyz
set char3=1
set num=0
:loop
set /a ran=%random%%%26
set char2=!char1:~%ran%,1!
set /a num1=%ran%+1
if %num% lss 10 (
echo %char3%|find "%char2%" 1>nul
if errorlevel 1 ( set char3=%char3%%char2%&echo %num1%--%char2%&set /a num+=1&goto loop ) else ( goto loop ) )
pause
|
|
2008-8-26 13:08 |
|
|
szww
初级用户
 
积分 59
发帖 28
注册 2007-3-23
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
望楼主分析一下高深的代码。
Please provide the specific code content that needs to be analyzed so that I can help you translate the relevant request and the code for analysis.
|
|
2008-8-26 13:24 |
|
|
heheguai
初级用户
 
积分 30
发帖 18
注册 2008-5-11
状态 离线
|
『第 24 楼』:
使用 LLM 解释/回答一下
@echo off&setlocal enabledelayedexpansion
set char1=abcdefghijklmnopqrstuvwxyz
set char3=1
set num=0
:loop
set /a ran=%random%%%26-------这句设置0--25 随机数字
set char2=!char1:~%ran%,1!-------这句取得随机数字所对应的字幕,比如随机数字5,那么对应的就是f,因为0对应与a
set /a num1=%ran%+1------这句是随机数字+1 这主要用后面的输出 1对应与a 作用
if %num% lss 10 ( -------这句是循环 循环10次
echo %char3%|find "%char2%" 1>nul -----这句判断这个随机数字是否已经产生过
if errorlevel 1 ( set char3=%char3%%char2%&echo %num1%--%char2%&set /a num+=1&goto loop ) else ( goto loop ) ) -------这句是接上句,如果曾经产生过这个随机数字,继续循环下一次,如果没有产生过,则循环计数+1,然后输出对应的数字和字母,然后在进行循环,这样可以去掉上次随机产生1,这次随机还是产生1这种情况,这样解析应该都理解了吧
pause
@echo off&setlocal enabledelayedexpansion
set char1=abcdefghijklmnopqrstuvwxyz
set char3=1
set num=0
:loop
set /a ran=%random%%%26-------This line sets a random number from 0 to 25
set char2=!char1:~%ran%,1!-------This line gets the character corresponding to the random number, for example, if the random number is 5, then it corresponds to 'f' because 0 corresponds to 'a'
set /a num1=%ran%+1------This line is the random number +1, which is mainly used for the subsequent output. 1 corresponds to 'a'
if %num% lss 10 ( -------This line is a loop, looping 10 times
echo %char3%|find "%char2%" 1>nul -----This line judges whether this random number has been generated before
if errorlevel 1 ( set char3=%char3%%char2%&echo %num1%--%char2%&set /a num+=1&goto loop ) else ( goto loop ) ) -------This line is connected to the previous line. If this random number has been generated before, continue to the next loop. If not, increment the loop count by 1, then output the corresponding number and letter, and then continue the loop, so as to remove the situation where the first random generation is 1 and the second random generation is still 1. I think this analysis is all understood
pause
|
|
2008-8-26 14:34 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 25 楼』:
使用 LLM 解释/回答一下
&&楼上兄弟的态度还是很认真的,值得称赞,但你的代码是不合题意的:
一、你生成的是一个对应关系,而这个对应关系本就是题目中事先给出的条件,并不需要再去生成;
二、根据你的代码只能生成10个互不同的纯数列或纯字母列,而题意是要求生成字母和数字组成并彼此间不存在对应关系的随机值列;
三、和前面其他的代码一样使用if判断+返回(在你的代码中表现为不累加计数),存在效率问题;
四、使用管道也降低了代码效率。
&&The attitude of the brother upstairs is still very serious and worthy of praise, but your code does not meet the requirements:
1. What you generated is a corresponding relationship, which is already a condition given in the question in advance and does not need to be generated again;
2. According to your code, only 10 different pure number sequences or pure letter sequences can be generated, while the question requires random value sequences composed of letters and numbers and having no corresponding relationship with each other;
3. The same as other previous codes, using if judgment + return (in your code, it is manifested as not accumulating the count), which has efficiency problems;
4. Using pipes also reduces code efficiency.
|

批处理之家新域名:www.bathome.net |
|
2008-8-26 16:13 |
|