|
PPdos
高级用户
   
积分 783
发帖 268
注册 2006-12-26
状态 离线
|
『第 16 楼』:
谢谢修改 一时兴奋 发的快了点 嘿嘿~ ^^
使用 LLM 解释/回答一下
Originally posted by rochan at 2006-12-28 12:55 PM:
9楼代码有点误差..依次输入 1 2 3 4 5 6 7 8 后 k.txt文件中 会出现 8642打开 ECHO。...而不是 87654321
我改了一下..测试过了.成功!!
代码如下:
@echo o ...
Originally posted by rochan at 2006-12-28 12:55 PM:
There is a slight error in the code on floor 9.. After entering 1 2 3 4 5 6 7 8 in sequence, the k.txt file will have "8642 open ECHO..." instead of "87654321"
I made a change.. Tested and it worked!!
The code is as follows:
@echo o ...
|
|
2006-12-29 02:57 |
|
|
weapfe
初级用户
 
积分 144
发帖 66
注册 2006-11-30
状态 离线
|
『第 17 楼』:
好像13樓的代碼也有一些問題。。。
使用 LLM 解释/回答一下
9楼代码有点误差..依次输入 1 2 3 4 5 6 7 8 后 k.txt文件中 会出现 8642打开 ECHO。...而不是 87654321
我改了一下..测试过了.成功!!
代码如下:
CODE: [Copy to clipboard]
--------------------------------------------------------------------------------
@echo off
if not exist k.txt echo. >k.txt
:x
set /p a=<k.txt
set /p b=输入的字符:
:::echo %b% >>k.txt
echo %b%%a% >k.txt
goto x
運行後,我輸入987後,再連續點3次回車,關閉CMD後,打開k.txt看為777789。。。。能改進這個問題否??
Floor 9's code has some errors.. After entering 1 2 3 4 5 6 7 8 in sequence, the k.txt file will have 8642 instead of 87654321.
I made a change.. Tested it and it worked!!
The code is as follows:
CODE:
--------------------------------------------------------------------------------
@echo off
if not exist k.txt echo. >k.txt
:x
set /p a=<k.txt
set /p b=Enter the character:
:::echo %b% >>k.txt
echo %b%%a% >k.txt
goto x
After running, I entered 987, then pressed Enter 3 times in a row, closed the CMD, and opened k.txt to see 777789... Can this problem be improved??
|
|
2006-12-29 19:09 |
|
|
PPdos
高级用户
   
积分 783
发帖 268
注册 2006-12-26
状态 离线
|
|
2006-12-29 19:44 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
 『第 19 楼』:
使用 LLM 解释/回答一下
看到国外的批处理脚本写的那么精彩, 再看我们论坛对批处理的理解只是简单玩玩而已, 不免有些感触.
国外写的批处理不但对算法有很深的研究, 对三种基本结构的使用也很精通. 似乎中国人对批处理研究却没那么深入. 原因在于没有把编程的思想应用到批处理中来.
其实批处理脚本有很好的灵活性, 甚至可以模拟实现一些高级语言的功能. 这又建立在对算法的研究的数据结构的理解上. 如果大家能把这两点做好, 相信可以把论坛的批处理推水平推向一个更高的层次, 使批处理有更广的应用范围, 吸引更多的人来交流学习~!~
这个问题我采用数组的方法来解决, 当然不止这一种方法:
@echo off
setlocal enabledelayedexpansion
set num=0
:go
set /a num+=1
set /p ii%num%=Input %num% number:
if %num% lss 10 goto go
for /l %%i in (%num%,-1,1) do echo !ii%%i!
pause
Seeing that foreign batch scripts are written so wonderfully, while looking at our forum's understanding of batch processing just being simple play, it can't help but make some feelings.
Foreign - written batch processing not only has a deep study of algorithms, but is also proficient in the use of the three basic structures. It seems that the Chinese have not studied batch processing so deeply. The reason is that they haven't applied programming ideas to batch processing.
In fact, batch script has very good flexibility, and can even simulate and realize some functions of high - level languages. This is also based on the understanding of data structures in algorithm research. If everyone can do these two points well, I believe that the level of batch processing in the forum can be pushed to a higher level, making batch processing have a wider application range and attracting more people to communicate and learn~!~
I solved this problem using the array method, and of course there is more than one method:
@echo off
setlocal enabledelayedexpansion
set num=0
:go
set /a num+=1
set /p ii%num%=Input %num% number:
if %num% lss 10 goto go
for /l %%i in (%num%,-1,1) do echo !ii%%i!
pause
此帖被 +16 点积分 点击查看详情 评分人:【 redtek 】 | 分数: +5 | 时间:2006-12-30 01:03 | 评分人:【 zh159 】 | 分数: +5 | 时间:2006-12-30 01:09 | 评分人:【 lxmxn 】 | 分数: +6 | 时间:2006-12-30 05:02 |
|
|

业精于勤而荒于嬉,形成于思而毁于随。 |
|
2006-12-30 00:43 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
 『第 20 楼』:
使用 LLM 解释/回答一下
好像楼主要求输出在同一行,pengfei的代码做一点修改:
@echo off
setlocal enabledelayedexpansion
set num=0
:go
set /a num+=1
set /p ii%num%=Input %num% number:
if %num% lss 10 goto go
for /l %%i in (%num%,-1,1) do @set/p=!ii%%i!<nul
pause
It seems that the building owner requires the output to be in the same line, and make a little modification to pengfei's code:
@echo off
setlocal enabledelayedexpansion
set num=0
:go
set /a num+=1
set /p ii%num%=Input %num% number:
if %num% lss 10 goto go
for /l %%i in (%num%,-1,1) do @set/p=!ii%%i!<nul
pause
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2006-12-30 01:01 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
19楼的得全部输入完毕后才写入文件,如果原文件已有内容要加入就不行了
国人本来就对英语不是很熟悉,只能具体方法具体应用了,更不用说编程了(估计真正会编程的不在多数)
After all the input in building 19 is completed, it is written to the file. If there is existing content in the original file and you want to add to it, it won't work.
Chinese people are originally not very familiar with English. We can only apply specific methods specifically. Let alone programming (it is estimated that not many people really know how to program).
|
|
2006-12-30 01:08 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
Originally posted by zh159 at 2006-12-30 01:08:
19楼的得全部输入完毕后才写入文件,如果原文件已有内容要加入就不行了
国人本来就对英语不是很熟悉,只能具体方法具体应用了,更不用说编程 ...
数组已经构造好, 灵活修改就可以适应各种需要了.
英语的确很重要, 但不是主要原因. 中国人善长思维, 最伟大的谋略家在中国, 同时中国有一流的数学家. 但中国人却写不出优秀的编译器, 至今也没有能够独立编写操作系统内核的奇才, 不免是中国教育模式的失败.
编程具体还在于理解.
Originally posted by zh159 at 2006-12-30 01:08:
The user on floor 19 writes all the content into the file only after completing the input, which doesn't work if you want to add content to an existing file.
Chinese people are originally not very familiar with English, so we can only apply specific methods specifically, let alone programming...
The array has been constructed, and flexible modifications can adapt to various needs.
English is indeed important, but it's not the main reason. Chinese people are good at thinking. The greatest strategists are in China, and China also has first-class mathematicians. But Chinese people can't write excellent compilers, and there are still no geniuses who can independently write operating system kernels. It is undoubtedly a failure of China's education model.
Programming specifically depends on understanding.
|

业精于勤而荒于嬉,形成于思而毁于随。 |
|
2006-12-30 01:36 |
|
|
9527
银牌会员
     努力做坏人
积分 1185
发帖 438
注册 2006-8-28 来自 北京
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
同意pengfei兄的想法,确实是,编程最大的障碍不在语言上,而是在思想和主观对其的理解上,很多地方我们需要和别人学,学的是他们考虑问题的方式和方法,我们真应该反省一下啦
Agree with Brother pengfei's idea. Indeed, the biggest obstacle in programming is not in the language, but in the thinking and subjective understanding of it. There are many places where we need to learn from others, learning their ways and methods of thinking. We really should reflect on it.
|

我今后在论坛的目标就是做个超级坏人!!! |
|
2006-12-30 02:41 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 24 楼』:
使用 LLM 解释/回答一下
看来9527兄对此也有同感, 算法和数据结构博大精深, 不深入理解的话编程也会寸步难行.
论坛的批处理需要向国外的同行学习. 用先进的算法来解决问题.
It seems that Brother 9527 also has the same feeling about this. Algorithms and data structures are profound and extensive. Without in-depth understanding, programming will also be extremely difficult.
The batch processing of the forum needs to learn from foreign peers. Use advanced algorithms to solve problems.
|

业精于勤而荒于嬉,形成于思而毁于随。 |
|
2006-12-30 03:09 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 25 楼』:
使用 LLM 解释/回答一下
不一定越难的方法就是好方法,我们的目的是解决问题,我想我们最重要的是思路,不管什么方法,越多越好,不能一味的追求算法
Not necessarily the more difficult method is the good method. Our purpose is to solve the problem. I think the most important thing for us is the thinking. No matter what method, the more the better. We can't blindly pursue the algorithm
|
|
2006-12-30 03:26 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 26 楼』:
使用 LLM 解释/回答一下
嗯,好的要学习,罗嗦的就......
想起前段时间有人贴上来一段老外的获取系统当前日期的代码,算法完善一大堆;而我们的基本上就两三行-_-|||
该用算法的用算法,该简化的就简化
Last edited by zh159 on 2006-12-29 at 03:13 PM ]
Well, okay, need to study. The wordy ones are just...
Recall that some time ago someone posted a segment of code from a foreigner to get the current system date, with a lot of perfect algorithms; while ours is basically two or three lines -_-|||
Use algorithms where they are needed, simplify where they can be simplified
Last edited by zh159 on 2006-12-29 at 03:13 PM ]
|
|
2006-12-30 04:11 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 27 楼』:
使用 LLM 解释/回答一下
算法就是解决问题的步骤, 好的算法可以提高效率, 简化程序. 论坛里发的批处理大都是解决一些不太复杂的问题, 可能对算法不太重要. 但做一些复杂的操作或超出DOS命令的应用范围时, 我们就得采取迂回战术, 用各种方法得到我们想要的结果. 你就会感到算法是多么重要.
熟悉各种算法对写脚本的重要性自然不言而喻, 否则一遇到复杂的问题就没撤了.
An algorithm is the step to solve a problem. A good algorithm can improve efficiency and simplify the program. Most batch processes posted in the forum are to solve some less complex problems, and maybe the algorithm is not that important. But when doing some complex operations or going beyond the application scope of DOS commands, we have to adopt a roundabout way and use various methods to get the results we want. Then you will feel how important the algorithm is.
It goes without saying that being familiar with various algorithms is important for writing scripts, otherwise, you will be at a loss when encountering complex problems.
|

业精于勤而荒于嬉,形成于思而毁于随。 |
|
2006-12-30 04:34 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 28 楼』:
使用 LLM 解释/回答一下
Originally posted by vkill at 2006-12-30 03:26:
不一定越难的方法就是好方法,我们的目的是解决问题,我想我们最重要的是思路,不管什么方法,越多越好,不能一味的追求算法
算法是解决问题的步骤, 兄强调解决问题的思路的重要性. 不是和不能一味追求算法矛盾吗?
研究算法的最终目的是写出运行效率高, 代码简洁的程序或脚本.
写复杂的脚本没有一个好的算法是不行的.
Last edited by pengfei on 2006-12-30 at 04:41 AM ]
Originally posted by vkill at 2006-12-30 03:26:
Not necessarily the more difficult method is the better method. Our purpose is to solve the problem. I think the most important thing for us is the thinking. No matter what method, the more the better. We can't blindly pursue algorithms.
Algorithms are the steps to solve problems. Brother emphasizes the importance of the thinking to solve problems. Isn't it contradictory to not being able to blindly pursue algorithms?
The ultimate purpose of researching algorithms is to write programs or scripts with high running efficiency and concise code.
It is impossible to write complex scripts without a good algorithm.
Last edited by pengfei on 2006-12-30 at 04:41 AM ]
|

业精于勤而荒于嬉,形成于思而毁于随。 |
|
2006-12-30 04:39 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 29 楼』:
使用 LLM 解释/回答一下
嗯
不过要真想融会贯通还得下苦功夫才行(时间+精力啊)
Well, but to really understand thoroughly, one still needs to put in hard work (time + energy, etc.)
|
|
2006-12-30 04:43 |
|
|
tao0610
高级用户
    朦胧的世界
积分 579
发帖 218
注册 2006-10-24
状态 离线
|
『第 30 楼』:
使用 LLM 解释/回答一下
19楼的代码其实就是对输入倒序排列输出而已.但对楼主的问题并不很适合.
而13楼基本已经给好的解决方法.
解决问题有多种方法,但不需要盲目追求算法的" 先进性"
毕竟看一个程序的好坏不是看它的算法有多复杂,而是看它解决问题的效果.
用 小打小闹来解决问题,正是批处理的优点.
@echo off
if not exist k.txt echo. >k.txt
:x
set b=
set /p a=<k.txt
set /p b=输入的字符:
if "%b%"=="" goto :eof
echo %b%%a% >k.txt
goto x
Last edited by tao0610 on 2006-12-29 at 04:28 PM ]
The code on the 19th floor is actually just about reversing the input and output, but it's not very suitable for the original poster's question. And the solution on the 13th floor has basically been given.
There are multiple ways to solve problems, but there's no need to blindly pursue the "advanced nature" of algorithms. After all, whether a program is good or not isn't judged by how complex its algorithm is, but by the effect of it solving the problem. Using "simple and practical" methods to solve problems is precisely the advantage of batch processing.
@echo off
if not exist k.txt echo. >k.txt
:x
set b=
set /p a=<k.txt
set /p b=输入的字符:
if "%b%"=="" goto :eof
echo %b%%a% >k.txt
goto x
Last edited by tao0610 on 2006-12-29 at 04:28 PM ]
|

认识自己,降伏自己,改变自己,才能改变别人! |
|
2006-12-30 05:26 |
|