|
pusofalse
银牌会员
    
积分 1604
发帖 646
注册 2008-4-13
状态 离线
|
『楼 主』:
[求助]文本输出~
使用 LLM 解释/回答一下
转自批处理之家
a.txt:
ababababababababa
输出:
ababababababababa
aba a aba ab b b
a a ab a b
a ab b
a
空格位置是随机产生的,但纵向都是同一字母。。。
Transferred from Batch Processing Home
a.txt:
ababababababababa
Output:
ababababababababa
aba a aba ab b b
a a ab a b
a ab b
a
The positions of the spaces are randomly generated, but the same letter is in the same column vertically...
|
|
2008-5-6 22:44 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 2 楼』:
这道题有难度啊!!!
使用 LLM 解释/回答一下
@echo off&setlocal enabledelayedexpansion
set str=ababababababababa
echo %str%
:begin
set n=0&set m=0&set "var="
set /a a=%random%%%17+1,b=%random%%%17+1,c=%random%%%17+1
if %a% equ %b% goto begin
if %a% equ %c% goto begin
if %b% equ %c% goto begin
:lp
set /a n+=1
for %%i in (%a% %b% %c%) do if %%i equ %n% set m=1
if %m% equ 0 (
set var=!var!%str:~,1%
) else (
set "var=!var! "
)
set str=%str:~1%&set m=0
if defined str goto lp
if "!var!"==" " pause>nul&goto :eof
echo !var!
set str=!var!&goto begin
Last edited by zw19750516 on 2008-5-7 at 11:01 AM ]
```batch
@echo off&setlocal enabledelayedexpansion
set str=ababababababababa
echo %str%
:begin
set n=0&set m=0&set "var="
set /a a=%random%%%17+1,b=%random%%%17+1,c=%random%%%17+1
if %a% equ %b% goto begin
if %a% equ %c% goto begin
if %b% equ %c% goto begin
:lp
set /a n+=1
for %%i in (%a% %b% %c%) do if %%i equ %n% set m=1
if %m% equ 0 (
set var=!var!%str:~,1%
) else (
set "var=!var! "
)
set str=%str:~1%&set m=0
if defined str goto lp
if "!var!"==" " pause>nul&goto :eof
echo !var!
set str=!var!&goto begin
```
Last edited by zw19750516 on 2008-5-7 at 11:01 AM ]
|

批处理之家新域名:www.bathome.net |
|
2008-5-7 11:00 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 3 楼』:
上面还是没完全合楼主的要求:
使用 LLM 解释/回答一下
@echo off&setlocal enabledelayedexpansion
set str=ababababababababa
echo %str%
:begin
set n=0&set m=0&set x=0&set "var="
:set
set /a a=%random%%%17+1
for %%i in (%code%) do if %%i equ %a% goto set
set /a x+=1&set code=%code% %a%
if %x% lss 3 goto set
:lp
set /a n+=1
for %%i in (%code%) do if %%i equ %n% set m=1
if %m% equ 0 (
set var=!var!%str:~,1%
) else (
set "var=!var! "
)
set str=%str:~1%&set m=0
if defined str goto lp
if "!var!"==" " pause>nul&goto :eof
echo !var!
set str=!var!&goto begin
```@echo off&setlocal enabledelayedexpansion
set str=ababababababababa
echo %str%
:begin
set n=0&set m=0&set x=0&set "var="
:set
set /a a=%random%%%17+1
for %%i in (%code%) do if %%i equ %a% goto set
set /a x+=1&set code=%code% %a%
if %x% lss 3 goto set
:lp
set /a n+=1
for %%i in (%code%) do if %%i equ %n% set m=1
if %m% equ 0 (
set var=!var!%str:~,1%
) else (
set "var=!var! "
)
set str=%str:~1%&set m=0
if defined str goto lp
if "!var!"==" " pause>nul&goto :eof
echo !var!
set str=!var!&goto begin
```
|

批处理之家新域名:www.bathome.net |
|
2008-5-7 11:52 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
此题的真正要求是 a和b的总数是60个,且第一行第一个字母也是随机的,并不固定是a,第一行的字母总数也是随机的.
Last edited by 26933062 on 2008-5-7 at 12:04 PM ]
The real requirement of this question is that the total number of a and b is 60, and the first letter of the first row is also random and not fixed as a, and the total number of letters in the first row is also random.
Last edited by 26933062 on 2008-5-7 at 12:04 PM ]
|

致精致简! |
|
2008-5-7 12:02 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 5 楼』:
请说详细点了:
使用 LLM 解释/回答一下
对于楼主的题意我的代码已可以做到,但不知道原题是怎么样的,LS可以贴出来吗?
Regarding the question of the original poster, my code can already achieve it, but I don't know what the original question was. Can the LS post it?
|

批处理之家新域名:www.bathome.net |
|
2008-5-7 12:04 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
要求:
不产生临时文件,生成如楼主所提供的样本格式文件.
具体要求:
a和b的总数为60个,每行的字母总数及位置都是随机的
Requirements:
Do not generate temporary files, and generate the sample format file as provided by the original poster.
Specific requirements:
The total number of a and b is 60, and the total number of letters per line and their positions are random
|

致精致简! |
|
2008-5-7 12:07 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
条件好像不够吧,每行最多多少个字符啊?如没这个条件,不一行就做到了啊
The conditions seem not enough. How many characters at most per line? If there is no such condition, it would have been done in one line.
|

批处理之家新域名:www.bathome.net |
|
2008-5-7 12:13 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
要求的就是随机,如果可能的话一行也有可能.
应该是随机产生a或b,是一个一个产生的.总数为60个.
What is required is randomness. If possible, it could be one line. It should be generating a or b one by one. The total number is 60.
|

致精致简! |
|
2008-5-7 12:16 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 9 楼』:
先发一个吧:
使用 LLM 解释/回答一下
echo off
set "str=ab "&set m=0
:begin
set /a a=%random%%%60+1
set "var="
:lp
set /a b=%random%%%3
call,set c=%%str:~%b%,1%%
if not "%c%"==" " set /a m+=1
set /a n+=1&set var=%c%%var%
if %n% lss %a% goto lp
echo.%var%
if %m% lss 60 goto begin
pause>nul
```batch>
echo off
set "str=ab " & set m=0
:begin
set /a a=%random%%%60+1
set "var="
:lp
set /a b=%random%%%3
call,set c=%%str:~%b%,1%%
if not "%c%"==" " set /a m+=1
set /a n+=1 & set var=%c%%var%
if %n% lss %a% goto lp
echo.%var%
if %m% lss 60 goto begin
pause>nul
```
|

批处理之家新域名:www.bathome.net |
|
2008-5-7 12:47 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
ls测试了么?
要的是顶楼的那种格式。
Have you tested the ls? What is needed is the format of the top post.
|

致精致简! |
|
2008-5-7 14:15 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 11 楼』:
先理一下思路:
使用 LLM 解释/回答一下
&&按兄弟的意思就是先随机生成一个由a和b随机组成的字符总数小于60的字符串,然后逐行将字符串中的三个字符替换为空格,当字符总数(不含空格)达到60时终止是吧?
但这样我认为会有问题,因为总会出现一行中不够三个字符的情况啊,同时还会出现第二行字符总数就超出60个的情况,再说真要实现上面的确实难度太大了!!!
Last edited by zw19750516 on 2008-5-7 at 03:32 PM ]
&& According to brother's meaning, it is to first randomly generate a string composed of a and b with the total number of characters less than 60, and then replace three characters in the string with spaces line by line, and terminate when the total number of characters (excluding spaces) reaches 60. But I think there will be problems here, because there will always be a situation where there are not enough three characters in one line, and at the same time, the situation where the total number of characters in the second line exceeds 60 will occur. Moreover, it is really too difficult to implement the above!
Last edited by zw19750516 on 2008-5-7 at 03:32 PM ]
|

批处理之家新域名:www.bathome.net |
|
2008-5-7 15:31 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 12 楼』:
终于还是写出来了,确实难!!!
使用 LLM 解释/回答一下
@echo off&setlocal enabledelayedexpansion
set "str=ab"&set /a a=%random%%%60+1
:begin
set /a b=%random%%%2
set c=!str:~%b%,1!&set var=%var%!c!
set /a n+=1
if %n% lss %a% goto begin
echo 下面为本次生成的字符串:
echo %var%&set code=%var%
echo 下面输出的字符(不含空格)总数为60个:
set "str="&set n=0
:lp
if !n! lss 60 if defined var (
set /a b=%random%%%2
if !b! equ 0 (
set "b= "
) else (
set b=!var:~,1!&set /a n+=1
)
set str=%str%!b!
set var=%var:~1%
goto lp
)
echo.%str%
if !n! lss 60 set str=&set var=%code%&goto lp
pause>nul
如要实现递减输出就难以满足字符总数为60个的要求了,如当原始生成的字符串为:a,就最多只有一行和一个字符了。
Last edited by zw19750516 on 2008-5-7 at 05:28 PM ]
```
@echo off&setlocal enabledelayedexpansion
set "str=ab"&set /a a=%random%%%60+1
:begin
set /a b=%random%%%2
set c=!str:~%b%,1!&set var=%var%!c!
set /a n+=1
if %n% lss %a% goto begin
echo The generated string for this time is:
echo %var%&set code=%var%
echo The total number of characters (excluding spaces) output below is 60:
set "str="&set n=0
:lp
if !n! lss 60 if defined var (
set /a b=%random%%%2
if !b! equ 0 (
set "b= "
) else (
set b=!var:~,1!&set /a n+=1
)
set str=%str%!b!
set var=%var:~1%
goto lp
)
echo.%str%
if !n! lss 60 set str=&set var=%code%&goto lp
pause>nul
```
If you want to achieve decremental output, it is difficult to meet the requirement that the total number of characters is 60. For example, when the originally generated string is: a, there will be at most one line and one character.
Last edited by zw19750516 on 2008-5-7 at 05:28 PM ]
|

批处理之家新域名:www.bathome.net |
|
2008-5-7 16:30 |
|
|
uemuem
初级用户
 
积分 153
发帖 68
注册 2006-10-12 来自 上海
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
Originally posted by 26933062 at 2008-5-7 12:16:
要求的就是随机,如果可能的话一行也有可能.
应该是随机产生a或b,是一个一个产生的.总数为60个.
你好像比LZ还LZ。。。<img src="images/smilies/face-smile-big.png" align="absmiddle" border="0">
Originally posted by 26933062 at 2008-5-7 12:16:
What is required is randomness. If possible, it could be one line.
It should be randomly generating either a or b, generated one by one. The total number is 60.
You seem more like the LZ than the LZ... :D
|

个人主页-找餐厅:http://www.canting.cc |
|
2008-5-7 16:45 |
|
|
pusofalse
银牌会员
    
积分 1604
发帖 646
注册 2008-4-13
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
Originally posted by zw19750516 at 2008-5-7 04:30 PM:
@echo off&setlocal enabledelayedexpansion
set "str=ab"&set /a a=%random%%%60+1
:begin
set /a b=%random%%%2
set c=!str:~%b%,1!&set var=%var%!c!
set /a n+=1
if %n% l ...
高!确实高!虽然这段代码看起来还有点难度。。。。^_^
Originally posted by zw19750516 at 2008-5-7 04:30 PM:
@echo off&setlocal enabledelayedexpansion
set "str=ab"&set /a a=%random%%%60+1
:begin
set /a b=%random%%%2
set c=!str:~%b%,1!&set var=%var%!c!
set /a n+=1
if %n% l ...
Wow! Really amazing! Although this code still looks a bit challenging... ^_^
|
|
2008-5-7 17:55 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
回复 12 楼
不好意识,答案仍不正确,可能是我描述的不够清楚吧。
每个字母的正上方不能是空格。
这么说吧
随机生成第一个字母,比如说是a就把他写入新文件,然后再生成第二个字母,如果同上一个字母一样,则把这个字母写在上一个字母的正下方,否则就写在第一行。
回复 13 楼
什么东西。。。。。
Reply to floor 12
Sorry, the answer is still incorrect. Maybe I didn't describe it clearly enough.
There should be no space directly above each letter.
Let me put it this way
Randomly generate the first letter. For example, if it's "a", write it to the new file. Then generate the second letter. If it's the same as the previous letter, write this letter directly below the previous one; otherwise, write it in the first line.
Reply to floor 13
What on earth...
|

致精致简! |
|
2008-5-7 19:44 |
|