|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 31 楼』:
使用 LLM 解释/回答一下
Originally posted by 26933062 at 2008-7-11 15:18:
再来一个,思路清晰点的。
@echo off&setlocal enabledelayedexpansion
set "str1= 0 1 2 3 4 5 6 7 8 9"
set "str2= j i h g f e d c b a"
echo.&set /p n ...
小楼兄这个方案还是欠缺在通用性上面。
Originally posted by 26933062 at 2008-7-11 15:18:
Another one, with a clearer train of thought.
@echo off&setlocal enabledelayedexpansion
set "str1= 0 1 2 3 4 5 6 7 8 9"
set "str2= j i h g f e d c b a"
echo.&set /p n ...
Brother Xiaolou, this solution still lacks in generality.
|

批处理之家新域名:www.bathome.net |
|
2008-7-11 15:37 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
|
2008-7-11 15:40 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
|
2008-7-11 15:48 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 34 楼』:
使用 LLM 解释/回答一下
Originally posted by zw19750516 at 2008-7-11 15:48:
for /l %%a in (1 2 19) do (。。。
就这句。
对位数加了个判断和计算,这样应该可以了吧?
Originally posted by zw19750516 at 2008-7-11 15:48:
for /l %%a in (1 2 19) do (。。。
Just this sentence.
Added a judgment and calculation for the number of digits, should this be okay?
|

致精致简! |
|
2008-7-11 16:14 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
『第 35 楼』:
使用 LLM 解释/回答一下
我有分不
@echo off&setlocal enabledelayedexpansion
set/p p=请输入:
set str=abcdefghij
for /l %%i in (0 1 9) do set %%i=%%i&set/a !str:~%%i,1!=9-%%i
:lp
if defined p set .!%p:~,1%!=!%p:~,1%!&set p=!p:~1!&goto lp
for /l %%i in (0 1 9) do (
if defined .%%i (
set var1=!var1!%%i&set/a _%%i=9-%%i
call set var2=%%str:~!_%%i!,1%%!var2!
)else set var1=!var1!#&set var2=#!var2!
)
echo !var1! ^| !var2!
pause
I have points no
@echo off&setlocal enabledelayedexpansion
set/p p=Please enter:
set str=abcdefghij
for /l %%i in (0 1 9) do set %%i=%%i&set/a !str:~%%i,1!=9-%%i
:lp
if defined p set .!%p:~,1%!=!%p:~,1%!&set p=!p:~1!&goto lp
for /l %%i in (0 1 9) do (
if defined .%%i (
set var1=!var1!%%i&set/a _%%i=9-%%i
call set var2=%%str:~!_%%i!,1%%!var2!
)else set var1=!var1!#&set var2=#!var2!
)
echo !var1! ^| !var2!
pause
|

简单!简单!再简单! |
|
2008-7-11 16:50 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 36 楼』:
使用 LLM 解释/回答一下
Originally posted by terse at 2008-7-11 16:50:
我有分不
@echo off&setlocal enabledelayedexpansion
set/p p=请输入:
set str=abcdefghij
for /l %%i in (0 1 9) do set %%i=%%i&set/a !str:~%%i,1!=9-%%i
:lp
if defined p set ...
for /l %%i in (0 1 9)...
不通用,请兄弟仔细看下我顶楼的说明。
Originally posted by terse at 2008-7-11 16:50:
Do I have points?
@echo off&setlocal enabledelayedexpansion
set/p p=Please enter:
set str=abcdefghij
for /l %%i in (0 1 9) do set %%i=%%i&set/a !str:~%%i,1!=9-%%i
:lp
if defined p set ...
The for /l %%i in (0 1 9)... is not universal, please brother take a closer look at the instructions in my top post.
|

批处理之家新域名:www.bathome.net |
|
2008-7-11 17:01 |
|
|
quya
高级用户
    五星老土
积分 558
发帖 172
注册 2003-2-9 来自 江苏
状态 离线
|
 『第 37 楼』:
使用 LLM 解释/回答一下
我这个又是产生临时文件的, 初学者的思路, 不过通用性很好!
@echo off
set/p input=请输入:
rem " .%input%" 中"." 为了防止纯单数字(1-9?) 输入出现错误
echo .%input%>%temp%\temp.txt
set string=0123456789abcdefghij
set num=
:pro1
set /a num+=1
set strtmp=%string:~0,1%%string:~-1%
set str%num%=##
rem 下面这句是 findstr 类方面的应用
findstr %temp%\temp.txt>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
我自我感觉通用性最好,不相信可以验证, 高手可以按照我思路简化下, 我写的东西经常性带有冗余代码.
不产生临时文件的写法, 其实更简单, 我主要用惯了临时文件。
@echo off
set/p input=请输入:
set string=0123456789abcdefghij
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-11 at 07:33 PM ]
This is another one that generates temporary files. It's a beginner's approach, but it has very good generality!
@echo off
set/p input=Please enter:
rem " .%input%" The "." in it is to prevent errors when entering pure single-digit numbers (1-9?)
echo .%input%>%temp%\temp.txt
set string=0123456789abcdefghij
set num=
:pro1
set /a num+=1
set strtmp=%string:~0,1%%string:~-1%
set str%num%=##
rem The following line is an application of the findstr category
findstr %temp%\temp.txt>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
I feel that the generality is the best. You can verify if you don't believe it. Experts can simplify it according to my idea. The things I write often have redundant code.
The writing method that doesn't generate temporary files is actually simpler. I'm mainly used to using temporary files.
@echo off
set/p input=Please enter:
set string=0123456789abcdefghij
set num=
:pro1
set /a num+=1
set strtmp=%string:~0,1%%string:~-1%
set str%num%=##
rem The following line is an application of the findstr category
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-11 at 07:33 PM ]
|

我怎么找不到一个比我注册日期早的人? 难道我是传说中的超级管理员? 其实我只是个潜水冠军而已. |
|
2008-7-11 17:03 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 38 楼』:
使用 LLM 解释/回答一下
再来
@echo off&setlocal enabledelayedexpansion
set "str=0123456789abcdefghij"
set str1=!str!
:loop
set .!str:~0,1!=!str:~-1,1!
set .!str:~-1,1!=!str:~0,1!
set str=!str:~1,-1!
set /a nnn+=1
if defined str goto loop
for /f "tokens=2 delims==" %%a in ('set .') do set str1=!str1:%%a= %%a!
set /p num=请输入、可以不输入空格 &cls&set num=!num: =!
for %%i in (!str1!) do set num=!num:%%i= %%i!
for %%a in (!num!) do set num=!num! !.%%a!
for %%a in (!num!) do set _%%a=a
for %%a in (!str1!) do if defined _%%a (set var=!var!%%a) else set var=!var!#
echo.&echo !var:~0,%nnn%! !var:~%nnn%!
pause>nul
Last edited by 26933062 on 2008-7-13 at 11:10 AM ]
Again
@echo off&setlocal enabledelayedexpansion
set "str=0123456789abcdefghij"
set str1=!str!
:loop
set .!str:~0,1!=!str:~-1,1!
set .!str:~-1,1!=!str:~0,1!
set str=!str:~1,-1!
set /a nnn+=1
if defined str goto loop
for /f "tokens=2 delims==" %%a in ('set .') do set str1=!str1:%%a= %%a!
set /p num=Please enter, can not enter spaces &cls&set num=!num: =!
for %%i in (!str1!) do set num=!num:%%i= %%i!
for %%a in (!num!) do set num=!num! !.%%a!
for %%a in (!num!) do set _%%a=a
for %%a in (!str1!) do if defined _%%a (set var=!var!%%a) else set var=!var!#
echo.&echo !var:~0,%nnn%! !var:~%nnn%!
pause>nul
Last edited by 26933062 on 2008-7-13 at 11:10 AM ]
|

致精致简! |
|
2008-7-11 18:38 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
『第 39 楼』:
使用 LLM 解释/回答一下
Originally posted by zw19750516 at 2008-7-11 17:01:
for /l %%i in (0 1 9)...
不通用,请兄弟仔细看下我顶楼的说明。
当输入7时,输出如下:
#######7## | ##c#######
当输入a5时,输出如下:
#####5###9 | a###e#####
当输入12j时,输出如下:
012####### | #######hij
我想我的代码做到了
小弟愚笨 想不通那里不对 望zw19750516兄明示
Originally posted by zw19750516 at 2008-7-11 17:01:
for /l %%i in (0 1 9)...
Not universal, please brothers take a close look at the instructions in my top post.
When inputting 7, the output is as follows:
#######7## | ##c#######
When inputting a5, the output is as follows:
#####5###9 | a###e#####
When inputting 12j, the output is as follows:
012####### | #######hij
I think my code has achieved
Little brother is stupid, can't figure out where it's wrong, hope brother zw19750516 can give instructions
|

简单!简单!再简单! |
|
2008-7-11 20:35 |
|
|
quya
高级用户
    五星老土
积分 558
发帖 172
注册 2003-2-9 来自 江苏
状态 离线
|
『第 40 楼』:
使用 LLM 解释/回答一下
楼上的, 你的不通用性在于:
1. 如果两边少点字符, 你要修改代码多处
2. 最大的缺点是, 如果左右边互换, 你又要改,如果左边逆序呢? 如果左边有字母呢? 如果两边的字符毫无规律呢?
所以确实不通用。
The problem with what you have upstairs is:
1. If there are fewer characters on both sides, you need to modify multiple places in the code.
2. The biggest shortcoming is that if the left and right are swapped, you have to change it again. What if the left is reversed? What if there are letters on the left? What if the characters on both sides are completely irregular?
So it's really not universal.
|

我怎么找不到一个比我注册日期早的人? 难道我是传说中的超级管理员? 其实我只是个潜水冠军而已. |
|
2008-7-11 22:26 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 41 楼』:
使用 LLM 解释/回答一下
严重同意老土的,还有就是请兄弟每次解我的题时先看下顶楼的要求是不是改变了,因为本人出题的思路开始可能会欠慎密,但我会不断修改的,也难为兄弟们了。
I fully agree with Laotu. Also, please brothers check the requirements in the top post first when solving my problems each time, because my thinking of setting problems might be a bit careless at the beginning, but I will keep modifying it. It's also hard for the brothers.
|

批处理之家新域名:www.bathome.net |
|
2008-7-12 10:54 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 42 楼』:
使用 LLM 解释/回答一下
:loop
set .!str:~0,1!=!str:~-1,1!
set .!str:~-1,1!=!str:~0,1!
set str=!str:~1,-1!
set /a nnn+=1
if defined str goto loop
小楼兄这次的思路和我的第一个方案是一样的都是从两头同时截取字符,只是兄在处理技巧上更胜我一筹,加入了以本身为变量的赋值,学习了。
Last edited by zw19750516 on 2008-7-12 at 11:35 AM ]
:loop
set .!str:~0,1!=!str:~-1,1!
set .!str:~-1,1!=!str:~0,1!
set str=!str:~1,-1!
set /a nnn+=1
if defined str goto loop
Brother Xiaolou's idea this time is the same as my first plan, both intercepting characters from both ends at the same time. It's just that brother is more skilled in processing, adding the assignment with itself as a variable. I've learned.
Last edited by zw19750516 on 2008-7-12 at 11:35 AM ]
|

批处理之家新域名:www.bathome.net |
|
2008-7-12 10:58 |
|
|
quya
高级用户
    五星老土
积分 558
发帖 172
注册 2003-2-9 来自 江苏
状态 离线
|
『第 43 楼』:
使用 LLM 解释/回答一下
你们的代码我基本看不懂, 我看见 !变量!什么的就头痛, 所以不到万不得已就不用, 可以用CALL代替的就代替。(CALL也是最近才学的)
这次主动用上延迟变量算是我破天荒第一次了,实在想不出啥办法, 一般我都是抄人家延迟变量的代码的。
另外,你们的输入大多数要加空格隔开的, 不知道为什么,我想凭你们的技巧,肯定可以用别的办法,加个空格输入的时候多别扭啊。
I can't understand your code basically. I get a headache when I see !variables! and so on, so I don't use them unless it's absolutely necessary. I replace what can be replaced with CALL. (CALL is also something I just learned recently.)
This time taking the initiative to use delayed variables is my first time ever. I really can't think of any other way. Usually I just copy others' code for delayed variables.
Also, most of your inputs need to be separated by spaces. I don't know why. I think with your skills, there must be other ways. It's so awkward to input with spaces.
|

我怎么找不到一个比我注册日期早的人? 难道我是传说中的超级管理员? 其实我只是个潜水冠军而已. |
|
2008-7-12 12:36 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 44 楼』:
使用 LLM 解释/回答一下
另外,你们的输入大多数要加空格隔开的, 不知道为什么,我想凭你们的技巧,肯定可以用别的办法,加个空格输入的时候多别扭啊。
老土,要解决是不是问题(我25楼的代码就不是加空格输入的),但这样会使代码显得繁杂,本题的核心问题也不在对这个的处理上,因此,为了更加突出解题的核心代码,我第二个方案采用了加空格输入的办法。
Additionally, most of your inputs need to be separated by spaces. I don't know why. I think with your skills, you must be able to use other methods. It's so awkward to input with spaces.
Old-fashioned. To solve it, is it a problem? (The code in my 25th floor is not input with spaces), but this will make the code complicated. The core problem of this question is not on the processing of this. Therefore, in order to highlight the core code of solving the problem more, my second solution adopts the method of inputting with spaces.
|

批处理之家新域名:www.bathome.net |
|
2008-7-12 12:56 |
|
|
quya
高级用户
    五星老土
积分 558
发帖 172
注册 2003-2-9 来自 江苏
状态 离线
|
『第 45 楼』:
使用 LLM 解释/回答一下
我不敢苟同楼主观点。
综观最近几天的出题解题,我发现大家都有点走火入魔了,重技巧而轻实用。
程序最终是用来方便自己和大家的, 所以首先要人机界面友好,缺省设置合理,符合大多数人使用习惯,可以有个性化设置,其次兼容性好,再次就是运行速度快,占内存和硬盘空间少。
人机界面友好的例子如下:
1. 比如这个题目输入的时候一定要加个空格, 这就不爽
2. 比如运行的时候一开始一定要点一个什么东西,也不爽。
等等
像此类问题,用户每用一次都要去适应它就不好了, 不如把程序编得复杂点, 因为程序只编一次(当然调试是多次的), 但用户要用N次。我们公司用的EPR程序就一直在折磨我。
技巧应该用在的地方:
1. 不用该技巧无法编程的
2. 能显著改善运行速度的,比如循环语句的优化, 某些只运行一次的代码就无所谓了,如果过于追求技巧将会使代码维护困难。
3. 该用技巧的时候不用, 比如现在编程的模块化,使得一些编大型程序的程序员不动脑筋, 最后编的程序一点都没有人性化,合理化,例如运行结果会出现3.00头猪之类的结果。把数据库里计算机自动生成的ID等当成搜索条件,而用户需要的好记的搜索条件却很难找到,不隐藏根本和用户不打交道的字段等等。
暂时写这么多, 其实实际中我碰到的问题实在太多太多。
I can't agree with the LZ's view.
Looking at the problem - solving in the past few days, I find that everyone is a bit obsessed, emphasizing skills over practicality.
Programs are ultimately used to facilitate oneself and others, so first, the human - computer interface should be friendly, default settings should be reasonable, in line with the usage habits of most people, and there can be personalized settings. Second, compatibility should be good. Third, the running speed should be fast, and the memory and hard disk space occupied should be small.
Examples of a friendly human - computer interface are as follows:
1. For example, it is not pleasant that a space must be added when entering this question.
2. For example, it is not pleasant that something must be clicked at the beginning when running.
And so on.
For such problems, it is not good that users have to adapt every time they use it. It is better to make the program a bit more complicated because the program is only written once (of course, debugging is done multiple times), but users will use it N times. The EPR program used in our company has been torturing me all the time.
Places where skills should be used:
1. Where programming is impossible without this skill.
2. Where it can significantly improve the running speed, such as the optimization of loop statements. And some codes that run only once don't matter. If one pursues skills too much, it will make code maintenance difficult.
3. Where skills should be used but are not, for example, the modularization of programming nowadays makes some programmers who program large - scale programs not use their brains. Finally, the programs they write are not humanized or rationalized at all. For example, the running result will be something like 3.00 pigs. Taking the ID automatically generated by the database as the search condition, while the user - friendly search conditions are hard to find, and fields that don't interact with the user at all are not hidden, etc.
I'll write so much for now. Actually, I have encountered too many problems in practice.
|

我怎么找不到一个比我注册日期早的人? 难道我是传说中的超级管理员? 其实我只是个潜水冠军而已. |
|
2008-7-12 13:36 |
|