|
qzwqzw
银牌会员
     天的白色影子
积分 2343
发帖 636
注册 2004-3-6
状态 离线
|
『第 46 楼』:
使用 LLM 解释/回答一下
老土想得太多了
只有针对具体问题的解题代码
才需要考虑应用中的很多问题
比如异常处理、界面优化、缺省值等等
而现在讨论的只是一些原型化的代码
根本谈不上如何去应用
只需要抽象出问题的核心然后解决掉它就可以了
The old-fashioned person thinks too much. Only the problem-solving code for specific issues needs to consider many issues in the application, such as exception handling, interface optimization, default values, and so on. But what we are discussing now is just some prototypical code, which can't be talked about how to apply it at all. We just need to abstract the core of the problem and then solve it.
|
|
2008-7-12 13:55 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
  『第 47 楼』:
使用 LLM 解释/回答一下
无须输入空格
@echo off&setlocal enabledelayedexpansion
set/p p=请输入:
set str=27j834fi56a901bghcde
set st=!str!&set pt=!p!
:lp
set ..!p:~%n%,1!=ok&set/a n+=1
set .!str:~,1!=!str:~-1,1!
set str=!str:~1,-1!
if defined str goto lp
:lp1
if defined ..%st:~,1% (set var1=!var1!%st:~,1%&set var2=!.%st:~,1%!!var2!)else (
if defined ..!.%st:~,1%! (set var1=!var1!%st:~,1%&set var2=!.%st:~,1%!!var2!)else set var1=!var1!#&set var2=#!var2!)
set st=!st:~1,-1!&set pt=!pt:~1!
if defined st goto lp1
echo !var1! ^| !var2!
pause
No need to enter spaces
@echo off&setlocal enabledelayedexpansion
set/p p=Please enter:
set str=27j834fi56a901bghcde
set st=!str!&set pt=!p!
:lp
set ..!p:~%n%,1!=ok&set/a n+=1
set .!str:~,1!=!str:~-1,1!
set str=!str:~1,-1!
if defined str goto lp
:lp1
if defined ..%st:~,1% (set var1=!var1!%st:~,1%&set var2=!.%st:~,1!%%var2!)else (
if defined ..!.%st:~,1%! (set var1=!var1!%st:~,1%&set var2=!.%st:~,1!%%var2!)else set var1=!var1!#&set var2=#!var2!)
set st=!st:~1,-1!&set pt=!pt:~1!
if defined st goto lp1
echo !var1! ^| !var2!
pause
|

简单!简单!再简单! |
|
2008-7-13 03:11 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 48 楼』:
使用 LLM 解释/回答一下
这回对了。
兄这个if defined ..!.%st:~,1%!真用得叹为观止啊,学习了。
This is correct.
Brother, this if defined ..!.%st:~,1%! is really amazing, I've learned it.
|

批处理之家新域名:www.bathome.net |
|
2008-7-13 09:33 |
|
|
quya
高级用户
    五星老土
积分 558
发帖 172
注册 2003-2-9 来自 江苏
状态 离线
|
『第 49 楼』:
使用 LLM 解释/回答一下
还是要挑点毛病。
其他的我看不懂, 就这句 set str=27j834fi56a901bghcde
好像还是不太通用啊。
同志们,请原谅我,我水平不行,挑刺还可以。
Still need to pick some flaws.
I don't understand the others, just this line set str=27j834fi56a901bghcde
It still doesn't seem very universal.
Comrades, please forgive me, my level is not good, I can only pick flaws.
|

我怎么找不到一个比我注册日期早的人? 难道我是传说中的超级管理员? 其实我只是个潜水冠军而已. |
|
2008-7-13 09:53 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 50 楼』:
使用 LLM 解释/回答一下
Originally posted by quya at 2008-7-13 09:53:
还是要挑点毛病。
其他的我看不懂, 就这句 set str=27j834fi56a901bghcde
好像还是不太通用啊。
同志们,请原谅我,我水平不行,挑刺还可以。
老土,这个set是根据情况来的,如要对称的是数字和字母,就set str=数字+字母,如要对称的是数字和汉字,就set str=数字+汉字,如要对称关系是没有规律的,就如terse兄如此set了。
Originally posted by quya at 2008-7-13 09:53:
Still need to pick some flaws.
I can't understand the others, just this line set str=27j834fi56a901bghcde
It still seems not very universal.
Comrades, please forgive me, my level is not good, I can only pick flaws.
Old-fashioned, this set is based on the situation. For example, if it is to be symmetrical with numbers and letters, then set str=numbers+letters. If it is to be symmetrical with numbers and Chinese characters, then set str=numbers+Chinese characters. If the symmetrical relationship is irregular, then it is set as terse brother did.
|

批处理之家新域名:www.bathome.net |
|
2008-7-13 10:14 |
|
|
quya
高级用户
    五星老土
积分 558
发帖 172
注册 2003-2-9 来自 江苏
状态 离线
|
『第 51 楼』:
使用 LLM 解释/回答一下
Originally posted by zw19750516 at 2008-7-13 10:14 AM:
老土,这个set是根据情况来的,如要对称的是数字和字母,就set str=数字+字母,如要对称的是数字和汉字,就set str=数字+汉字,如要对称关系是没有规律的,就如terse兄如此set了。
我对你题的理解是对称和数字,字母无关。
只要找到输入的值, 就在那个位置显示, 然后再在那个位置的对称位置显示。数字和字母都可以乱序。
所以我对你们的解题思路都很疑惑。
比如像下面这样乱序和重复的, (有2个0), 也能显示正确。
但我目前还无法解决原来字符中有空格的。输入的时候倒是可以有空格。
@echo off
set/p input=请输入:
set "string=012t457689aycd0fghi3"
set num=
:pro1
set /a num+=1
set strtmp=%string:~0,1%%string:~-1%
set str%num%=##
rem 下面这句是 findstr 类方面的应用
echo %input%|findstr >nul&&set str%num%=%strtmp%
set string=%string:~1,-1%
if not defined string goto pro2
goto pro1
:pro2
setlocal enabledelayedexpansion
set str_1=x
for /l %%i in (1,1,%num%) do call set str_1=!str_1:~0,-1!%%str%%i%%
for /l %%i in (1,1,%num%) do call set str_2=%%str%%i%%!str_2:~1!
echo %str_1:~,-1% ^| %str_2:~1,-2%
pause
Last edited by quya on 2008-7-13 at 10:35 AM ]
Originally posted by zw19750516 at 2008-7-13 10:14 AM:
Old-fashioned, this set is based on the situation. For example, if you want to be symmetrical with numbers and letters, then set str=numbers+letters. If you want to be symmetrical with numbers and Chinese characters, then set str=numbers+Chinese characters. If the symmetrical relationship is irregular, then set it as terse brother did.
My understanding of your question is that symmetry has nothing to do with numbers and letters.
As long as you find the input value, it will be displayed at that position, and then displayed at the symmetrical position of that position. Both numbers and letters can be in random order.
So I am very confused about your problem-solving ideas.
For example, the following is random and repeated, (there are 2 zeros), it can also be displayed correctly.
But I currently can't solve the problem of spaces in the original characters. Spaces can be entered.
@echo off
set/p input=Please enter:
set "string=012t457689aycd0fghi3"
set num=
:pro1
set /a num+=1
set strtmp=%string:~0,1%%string:~-1%
set str%num%=##
rem The following sentence is an application of findstr class
echo %input%|findstr >nul&&set str%num%=%strtmp%
set string=%string:~1,-1%
if not defined string goto pro2
goto pro1
:pro2
setlocal enabledelayedexpansion
set str_1=x
for /l %%i in (1,1,%num%) do call set str_1=!str_1:~0,-1!%%str%%i%%
for /l %%i in (1,1,%num%) do call set str_2=%%str%%i%%!str_2:~1!
echo %str_1:~,-1% ^| %str_2:~1,-2%
pause
Last edited by quya on 2008-7-13 at 10:35 AM ]
|

我怎么找不到一个比我注册日期早的人? 难道我是传说中的超级管理员? 其实我只是个潜水冠军而已. |
|
2008-7-13 10:26 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 52 楼』:
使用 LLM 解释/回答一下
是可以乱序啊,你甚至还可以通过代码来生成,如:
@echo off
set code=0123456789abcdefghijklmnopqrstuvwxyz&set n=36
:again
set /a a=%random%%%n%
call,set a=%%code:~%a%,1%%
call,set code=%%code:%a%=%%
set str=%str%%a%&set /a n-=1
if %n% neq 16 goto again
echo %str%&pause>nul
It can be out of order. You can even generate it through code, such as:
@echo off
set code=0123456789abcdefghijklmnopqrstuvwxyz&set n=36
:again
set /a a=%random%%%n%
call,set a=%%code:~%a%,1%%
call,set code=%%code:%a%=%%
set str=%str%%a%&set /a n-=1
if %n% neq 16 goto again
echo %str%&pause>nul
|

批处理之家新域名:www.bathome.net |
|
2008-7-13 10:39 |
|
|
quya
高级用户
    五星老土
积分 558
发帖 172
注册 2003-2-9 来自 江苏
状态 离线
|
『第 53 楼』:
使用 LLM 解释/回答一下
那楼主通过你的乱序再检验一下所有的解题看看。
程序只能改 set code=任意字符 这句, 任意字符的意思是原来给定是什么,就写什么。
Last edited by quya on 2008-7-13 at 10:58 AM ]
Then the original poster uses your scrambling to re-examine all the solutions.
The program can only modify the line "set code=arbitrary characters". The meaning of arbitrary characters is that what was originally given, just write that.
Last edited by quya on 2008-7-13 at 10:58 AM ]
|

我怎么找不到一个比我注册日期早的人? 难道我是传说中的超级管理员? 其实我只是个潜水冠军而已. |
|
2008-7-13 10:55 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 54 楼』:
使用 LLM 解释/回答一下
呵呵,老土还真是执著啊,
你试试 38 楼的代码,
已经对人机交互作了处理,可以不输入空格,也可以输入。
缺点是: 任意字符中不能有重复的。
Hehe, the old-fashioned person is really persistent,
You can try the code on floor 38. It has handled human-computer interaction, and you can input without spaces or with spaces.
The shortcoming is: there should be no duplicates in any characters.
|

致精致简! |
|
2008-7-13 11:13 |
|
|
quya
高级用户
    五星老土
积分 558
发帖 172
注册 2003-2-9 来自 江苏
状态 离线
|
『第 55 楼』:
使用 LLM 解释/回答一下
Originally posted by 26933062 at 2008-7-13 11:13 AM:
呵呵,老土还真是执著啊,
你试试 38 楼的代码,
已经对人机交互作了处理,可以不输入空格,也可以输入。
缺点是: 任意字符中不能有重复的。
试了下 当 set "str=012t456789abcd6fghi3"
输入36 不能正确显示。
而我37楼代码完全准确, 总算胜了众高手一回。
只是感到自己还不算太笨,没别的意思啊。
Last edited by quya on 2008-7-13 at 11:34 AM ]
Originally posted by 26933062 at 2008-7-13 11:13 AM:
Hehe, Laotu is really persistent,
You can try the code on floor 38,
It has handled human-computer interaction, you can not enter spaces or can enter.
The shortcoming is: There should be no duplicates in any characters.
Tried when set "str=012t456789abcd6fghi3"
Entering 36 cannot display correctly.
But my code on floor 37 is completely accurate, finally won over the masters.
Just feel that I'm not too stupid, no other meaning.
Last edited by quya on 2008-7-13 at 11:34 AM ]
|

我怎么找不到一个比我注册日期早的人? 难道我是传说中的超级管理员? 其实我只是个潜水冠军而已. |
|
2008-7-13 11:32 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 56 楼』:
使用 LLM 解释/回答一下
Originally posted by quya at 2008-7-13 11:32:
试了下 当 set "str=012t456789abcd6fghi3"
输入36 不能正确显示。
而我37楼代码完全准确, 总算胜了众高手一回。
只是感到自己还不算太笨 ...
都说了不能有重复的,你这里有两个6啊?
Originally posted by quya at 2008-7-13 11:32:
Tried it. When set "str=012t456789abcd6fghi3"
Entering 36 does not display correctly.
And my code on floor 37 is completely accurate, finally winning over the experts.
Just feel that I'm not too stupid...
It's already said that there can't be duplicates. There are two 6s here?
|

致精致简! |
|
2008-7-13 11:42 |
|
|
quya
高级用户
    五星老土
积分 558
发帖 172
注册 2003-2-9 来自 江苏
状态 离线
|
『第 57 楼』:
使用 LLM 解释/回答一下
又想了一个, 这个应该是最简单的了。连延迟变量都没用。
@echo off
set/p input=请输入:
set string=0123456789abcdefghij
set "str= "
:loop
set str=%string:~-1%%str%%string:~0,1%
echo %input%|findstr >nul||set str=#%str:~1,-1%%#
set string=%string:~1,-1%
if not defined string goto end
goto loop
:end
for /f "tokens=1,2 delims= " %%i in ("%str%") do echo %%j ^| %%i
pause
其实我想用延迟变量, 但不会用, 刚开始我想类似下边这样写法。
setlocal EnableDelayedExpansion
set string=0123456789abcdefghij
for /l %%i in (1,1,10) do (
set string=!string:~1,-1!
echo !string!
if not defined string goto end)
我期望的结果是 变量 String 慢慢变短,但第一步不成功, 后边的构思就全完了。我真的一直不明白为什么我达不到我要的结果, 高人请指点, 谢谢!
Last edited by quya on 2008-7-14 at 10:39 AM ]
Another idea, this should be the simplest one. Not even using a delay variable.
@echo off
set/p input=Please enter:
set string=0123456789abcdefghij
set "str= "
:loop
set str=%string:~-1%%str%%string:~0,1%
echo %input%|findstr >nul||set str=#%str:~1,-1%%#
set string=%string:~1,-1%
if not defined string goto end
goto loop
:end
for /f "tokens=1,2 delims= " %%i in ("%str%") do echo %%j ^| %%i
pause
Actually I want to use delay variables, but I don't know how to use them. At first I thought of writing like the following.
setlocal EnableDelayedExpansion
set string=0123456789abcdefghij
for /l %%i in (1,1,10) do (
set string=!string:~1,-1!
echo !string!
if not defined string goto end)
My expected result is that the variable String gradually becomes shorter, but the first step is not successful, and then the subsequent ideas are all messed up. I really don't understand why I can't achieve the result, please experts give pointers, thank you!
Last edited by quya on 2008-7-14 at 10:39 AM ]
|

我怎么找不到一个比我注册日期早的人? 难道我是传说中的超级管理员? 其实我只是个潜水冠军而已. |
|
2008-7-13 19:38 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 58 楼』:
使用 LLM 解释/回答一下
老土,代码第一是考虑效率,第二才是简洁,你这个方案存在效率问题,同时('echo %str%')可以修改为("%str%")。
Old-fashioned. Efficiency is the first consideration in code, and simplicity is the second. Your solution has an efficiency issue, and at the same time ('echo %str%') can be modified to ("%str%").
|

批处理之家新域名:www.bathome.net |
|
2008-7-14 08:38 |
|
|
quya
高级用户
    五星老土
积分 558
发帖 172
注册 2003-2-9 来自 江苏
状态 离线
|
『第 59 楼』:
使用 LLM 解释/回答一下
我57楼这么简单的代码存在效率问题? 试简析下, 谢谢.
%str%已按你建议修改, 但我依旧不知其所以然. 当初光写了%str% ,程序把这个变量当文件, 才ECHO, 不知道可以加 "".
Last edited by quya on 2008-7-14 at 10:41 AM ]
Is there an efficiency issue with such a simple code in floor 57? Please briefly analyze it, thanks.
%str% has been modified as you suggested, but I still don't understand why. Originally, I just wrote %str%, and the program treated this variable as a file, so I used ECHO. I didn't know I could add "".
Last edited by quya on 2008-7-14 at 10:41 AM ]
|

我怎么找不到一个比我注册日期早的人? 难道我是传说中的超级管理员? 其实我只是个潜水冠军而已. |
|
2008-7-14 10:28 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 60 楼』:
使用 LLM 解释/回答一下
效率问题出在这里:echo %input%|findstr [%string:~-1%%string:~0,1%]>nul||set str=#%str:~1,-1%%#
在批处理中要尽量用if做判断,少用findstr。
The efficiency issue is here: echo %input%|findstr >nul||set str=#%str:~1,-1%%#
In batch processing, try to use if for judgment as much as possible and use findstr less.
|

批处理之家新域名:www.bathome.net |
|
2008-7-14 10:39 |
|