China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-28 16:56
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Text output~ View 2,800 Replies 47
Floor 16 Posted 2008-05-07 19:55 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
You say you are a sock puppet =。=
Floor 17 Posted 2008-05-07 20:40 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
Originally posted by 26933062 at 2008-5-7 19:44:
Reply to post 12
Sorry, the answer is still incorrect. Maybe I didn't describe it clearly enough.
The space cannot be directly above each letter.
Let me put it this way
Randomly generate the first letter. For example, if it is a, then...

It's not difficult to do this. You can slightly modify my code in post 12 to achieve it, but the difficulty is that it will then be difficult to meet the requirement of a total of 60 characters. For example, when there is only one a in the first line, the code is as follows:
@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 following is the generated string for this time:
echo %var%
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 var=%str%&set str=&goto lp
pause>nul
批处理之家新域名:www.bathome.net
Floor 18 Posted 2008-05-07 21:14 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
Hehe, it seems there's a big problem with my description. The number of characters in the first line in the result is never less than that in the second line, and the number of characters in the second line is never less than that in the third line...
致精致简!
Floor 19 Posted 2008-05-07 21:27 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
To be honest, I'm really confused by you. Why don't you, brother, write out the code!
批处理之家新域名:www.bathome.net
Floor 20 Posted 2008-05-07 21:33 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
Is it really that hard to understand? To be honest, you should know it by looking at the sample in the top post. It's just that the total number of a and b is set to 60. Which of the codes written by brother zw19750516 outputs the format of the top post?
致精致简!
Floor 21 Posted 2008-05-07 21:55 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
That's because I didn't understand it well. Just please brother write out the code to take a look!
批处理之家新域名:www.bathome.net
Floor 22 Posted 2008-05-07 22:21 ·  中国 山东 淄博 联通
银牌会员
★★★
Credits 1,604
Posts 646
Joined 2008-04-13 23:39
18-year member
UID 115804
Gender Male
Status Offline
abababababababababa
xbxbxxabaxxbaxxxa
xbxxxxaxaxxbaxxxx
xxxxxxaxaxxbaxxxx
xxxxxxxxaxxbxxxxx
xxxxxxxxxxxbxxxxx

x represents a space. For example, the second character in the first line is b, but in the fourth line, the second character becomes a space... In the fifth line, the second character must also be a space. If it becomes a space in the third line, then in subsequent lines, the second position must also be a space. I wonder if you can understand what I'm saying~~^_^
Floor 23 Posted 2008-05-07 22:22 ·  中国 江苏 常州 溧阳市 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
Misunderstood and deleted the post

[ Last edited by terse on 2008-5-7 at 11:10 PM ]
简单!简单!再简单!
Floor 24 Posted 2008-05-07 22:24 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
Originally posted by pusofalse at 2008-5-7 22:21:
ababababababababa
xbxbxxabaxxbaxxxa
xbxxxxaxaxxbaxxxx
xxxxxxaxaxxbaxxxx
xxxxxxxxaxxbxxxxx
xxxxxxxxxxxbxxxxx

x represents a space
For example, the 2nd character of the first line is b, and by the fourth line, the 2nd character...

If it is like this, please run my code of 17.
批处理之家新域名:www.bathome.net
Floor 25 Posted 2008-05-07 22:27 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Hope to change to a 90s way of thinking... The problem will be simpler...
Floor 26 Posted 2008-05-07 22:41 ·  中国 山东 淄博 联通
银牌会员
★★★
Credits 1,604
Posts 646
Joined 2008-04-13 23:39
18-year member
UID 115804
Gender Male
Status Offline
Originally posted by zw19750516 at 2008-5-7 10:24 PM:

If that's the case, please run my code at 17.


Hmm, if there is no limit on the number of elements, indeed it is like this... But I'm really sorry~ I just forgot to mention again that the sum of the number of a and b should be equal to 60.

The perseverance and research spirit of all the seniors are really admirable!
Floor 27 Posted 2008-05-07 23:02 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
&&Then I can only say that there is a problem with this question. It is very difficult to meet the three conditions of randomly generating strings, decreasing output, and the total number of output characters (excluding the original string and spaces) being 60.
  This depends on the first point: whether the number of characters in the originally generated string is large. For example, if the originally generated string has only one character, see who can ensure that no spaces are generated in the next 59 lines.
  Also depends on the second point: whether the number of spaces generated in each line is large. If more than 30 spaces are generated in the first line, it is恐怕 difficult to maintain the condition that the total number of output characters is 60.
批处理之家新域名:www.bathome.net
Floor 28 Posted 2008-05-07 23:08 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
Reply to post 23: terse

Your code is also incorrect. It's impossible to have duplicate letters horizontally in each row, like "bb" or "aa". It should be "abababab" or "bababa". Also, your code seems to display many redundant blank lines.

The total number of "a" and "b" is 60, but which positions are "a" and which are "b" is random.

However, adjacent left and right cannot be repeated, like "bb" is not allowed, unless it's "b space b", but the first row cannot have spaces. And all vertical rows must be the same.
致精致简!
Floor 29 Posted 2008-05-07 23:13 ·  中国 山东 淄博 联通
银牌会员
★★★
Credits 1,604
Posts 646
Joined 2008-04-13 23:39
18-year member
UID 115804
Gender Male
Status Offline
The person who tied the bell on the tiger must take it off.... Go to Batch Processing Home to have a look, but it seems that the source code hasn't been provided yet. The moderators there are also extremely powerful, just that they don't have time to surf the Internet.
Floor 30 Posted 2008-05-07 23:19 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Algorithm problem... I think the experts in the forum should still be able to solve it.

a and b total 60? The output you provided seems insufficient?
Forum Jump: