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-22 18:22
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Nine-nine multiplication table View 14,091 Replies 36
Floor 16 Posted 2007-02-01 06:04 ·  中国 山东 济南 电信
初级用户
Credits 125
Posts 44
Joined 2007-01-24 15:31
19-year member
UID 77555
Gender Female
Status Offline
Flooding....

@ECHO %DBG% OFF
SETLOCAL ENABLEDELAYEDEXPANSION

for /l %%i in (1,1,9) do (
for /l %%j in (1,1,%%i) do (
set /a h=%%i*%%j
set /p=%%i×%%j^=!h! <nul
if %%i==%%j echo.
)
)


Really became flooding.. It turns out the key is to control the layout...

But the layout problem is solved, :) Using Tab instead of spaces can do it. You don't need to spend effort on layout.

Tab cannot be displayed correctly in the forum...???

[ Last edited by qjbm on 2007-1-31 at 05:38 PM ]
Recent Ratings for This Post ( 4 in total) Click for details
RaterScoreTime
namejm +8 2007-02-11 00:27
ccwan +9 2007-02-11 00:40
PPdos +4 2007-02-13 17:05
huzixuan +2 2007-05-01 16:35
Floor 17 Posted 2007-02-01 09:15 ·  中国 广东 广州 番禺区 电信
初级用户
★★
Credits 197
Posts 77
Joined 2006-09-19 14:02
19-year member
UID 63074
Gender Male
Status Offline
Needs to be studied... Absorb
Floor 18 Posted 2007-02-10 18:53 ·  中国 山西 移动
初级用户
Credits 27
Posts 14
Joined 2007-02-10 16:57
19-year member
UID 79176
Gender Male
Status Offline
Like me who can only do dead work, ECHO output...
Floor 19 Posted 2007-02-11 00:31 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
qjbm uses the Tab key to control typesetting, which has streamlined a lot of code, great.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 20 Posted 2007-02-16 09:39 ·  中国 广西 梧州 岑溪市 联通
新手上路
Credits 11
Posts 5
Joined 2007-02-15 11:04
19-year member
UID 79561
Gender Male
Status Offline
Floor 21 Posted 2007-02-17 14:07 ·  中国 湖北 潜江 电信
高级用户
★★★
Credits 894
Posts 411
Joined 2007-02-17 12:15
19-year member
UID 79697
Gender Male
Status Offline
I've seen the power of batch commands.
Floor 22 Posted 2007-02-17 14:23 ·  中国 黑龙江 绥化 联通
初级用户
Credits 24
Posts 9
Joined 2007-02-09 23:52
19-year member
UID 79086
Gender Male
Status Offline
The typesetting of the brother on the 16th floor is still not as neat as the building owner's. Personally, I think the building owner's is perfect.

I think it can be simplified further.

@echo off
:: 99 multiplication table
setlocal enabledelayedexpansion
for /l %%a in (1,1,9) do (
for /l %%b in (1,1,%%a) do (
set /a i+=1
set /a ans=%%a*%%b
set ans=%%b×%%a=!ans!
set res=!res! !ans:~0,6!
if !i! equ %%a echo!res!&set res=& set i=0
)
)
pause
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
namejm +4 2007-02-21 03:53
Floor 23 Posted 2007-02-17 17:43 ·  美国 弗吉尼亚州 华盛顿县 Microsoft
高级用户
★★
Credits 783
Posts 268
Joined 2006-12-26 17:18
19-year member
UID 74627
Gender Male
Status Offline
16th floor has prompted: Tab cannot be displayed correctly in the forum

So you need to replace the space between !h! and <nul in the copy with the space of the Tab key

set /p=%%i×%%j^=!h! <nul
菩提本无树,明镜亦非台,本来无一物,何处惹尘埃.
Floor 24 Posted 2007-02-21 03:54 ·  中国 湖南 怀化 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
The code of spiegboy is very good, and extra points are given.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 25 Posted 2007-03-01 07:35 ·  中国 广东 东莞 电信
新手上路
Credits 18
Posts 6
Joined 2007-03-01 04:37
19-year member
UID 80446
Gender Male
Status Offline
I'm just a new member of this forum. I have many things I don't understand. Please take care of me. At the same time, I hope those who are willing to take apprentices and have good interpersonal relationships and kind hearts can add my QQ: 453803302.
Thanks a million!
Floor 26 Posted 2007-03-01 13:47 ·  中国 上海 闵行区 电信
初级用户
Credits 24
Posts 12
Joined 2007-02-28 16:58
19-year member
UID 80409
Gender Male
Status Offline
Floor 27 Posted 2007-05-01 16:37 ·  中国 安徽 芜湖 电信
高级用户
★★
Credits 537
Posts 219
Joined 2006-10-31 21:08
19-year member
UID 69036
Gender Male
From 芜湖
Status Offline
The moderators and Brother 16 wrote really well. When I just came in, I couldn't write either. Today I can also write one.

@echo off
set "num1=1"
set "flag=0"
:do
if %num1% lss %flag% (
set /a "num1+=1"
) else (
echo.
set "num1=1"
set /a "flag+=1"
)
set /a "num=%num1%*%flag%"
set/p=%num1%×%flag%=%num% <nul
if %num1% equ 9 (pause>nul&exit)
goto do
江湖远
碧空长
路茫茫

一个人漫无目的的奔跑,风,刺骨的冷....
Floor 28 Posted 2007-05-02 13:17 ·  中国 福建 福州 电信
新手上路
Credits 6
Posts 2
Joined 2007-05-02 12:41
19-year member
UID 87265
Gender Male
Status Offline
Ask, I'm a newbie. Just follow what the person above said, using **.XXX >**.XXX can implement the output, right? Then, for example, when I want to output a file, as long as I enter a file name, it can help me output it to a corresponding TXT file (or a fixed one like 1.TXT). How to do it?

[ Last edited by DarkDrgon on 2007-5-2 at 12:37 AM ]
如果长大就像起飞的气球
我宁愿
永远停留在地面
不起飞
Floor 29 Posted 2007-05-02 13:36 ·  中国 湖南 联通数据上网公共出口
社区乞丐
★★
gaoshou
Credits -16
Posts 77
Joined 2007-01-30 09:11
19-year member
UID 78105
Gender Male
Status Offline
Why do you need to press Enter?
:cool:
Floor 30 Posted 2007-05-08 11:24 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
I saw this post today. Here's a VBS version of the multiplication table from 1 to 9:



  1. Dim i, m, s
  2. For i = 1 To 9
  3. s = s & vbLf
  4. For m = 1 To i
  5. s = s & m & "×" & i & " = " & Left(i * m & " ", 2) & Space(2)
  6. Next
  7. Next
  8. MsgBox s,,"Multiplication Table from 1 to 9"
ccwan posted on: 2007-05-08 11:23
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Forum Jump: