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 16:52
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Nine-nine multiplication table View 14,090 Replies 36
Original Poster Posted 2006-12-26 13:00 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Christmas is really boring, so I post something boring to entertain everyone:

@echo off
:: Multiplication table of 9x9
set num=0
for /l %%i in (1,1,9) do (
for /l %%j in (1,1,%%i) do call :multiply %%i %%j
)
pause>nul
goto :eof

:multiply
set /a num+=1
set /a var=%1*%2
set var=%2×%1=%var%
set var=%var%
if %2 equ 1 (set var=%var:~0,5%) else set var=%var:~0,6%
set str=%str% %var%
if %num% equ %1 echo %str%&set str=&set num=0
goto :eof

  After a little modification, the layout is more regular.

[ Last edited by namejm on 2006-12-26 at 08:14 AM ]
Recent Ratings for This Post ( 5 in total) Click for details
RaterScoreTime
lxmxn +4 2006-12-26 13:54
redtek +7 2006-12-26 21:42
jmz573515 +4 2006-12-26 22:35
ccwan +5 2006-12-27 21:40
oilio +2 2007-02-11 03:06
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 2 Posted 2006-12-26 13:57 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  Got it~

  The layout is very neat, and the nested for loops are also classic.
Floor 3 Posted 2006-12-26 21:43 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Wow, awesome~! The output is also so beautiful~~~ Appreciate it!!!


1×1=1
1×2=2 2×2=4
1×3=3 2×3=6 3×3=9
1×4=4 2×4=8 3×4=12 4×4=16
1×5=5 2×5=10 3×5=15 4×5=20 5×5=25
1×6=6 2×6=12 3×6=18 4×6=24 5×6=30 6×6=36
1×7=7 2×7=14 3×7=21 4×7=28 5×7=35 6×7=42 7×7=49
1×8=8 2×8=16 3×8=24 4×8=32 5×8=40 6×8=48 7×8=56 8×8=64
1×9=9 2×9=18 3×9=27 4×9=36 5×9=45 6×9=54 7×9=63 8×9=72 9×9=81


Reminds me of the time when I recited this thing when I was a kid, haha...
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 4 Posted 2006-12-26 22:34 ·  中国 辽宁 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
Good stuff
Don't know how to output it to a file?
Floor 5 Posted 2006-12-26 22:51 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
```
The moderator's .bat > multiplication table.txt
```

After execution (the screen shows nothing because there is still a pause that requires you to press a key), press Enter, and it's done :)

After execution, the content is output to the file "multiplication table.txt".
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
lxmxn +2 2006-12-27 02:40
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 6 Posted 2006-12-26 22:59 ·  中国 辽宁 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
Got it, such a simple principle, sigh~~
Floor 7 Posted 2006-12-27 02:41 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Originally posted by redtek at 2006-12-26 09:51:

The moderator's .bat > Multiplication Table.txt


After execution (the screen shows nothing because there is another pause that requires you to press a key), press Enter, and it's done : )

After execution, the content is output...


  Brother didn't say, I didn't know this method. Sweat... Learned it.
Floor 8 Posted 2006-12-27 07:05 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Brother namejm likes to study, which is worthy of learning
Floor 9 Posted 2006-12-27 08:16 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline

Brother didn't say, I didn't know this method yet. Sweat... Learned.


……
Floor 10 Posted 2007-01-01 04:46 ·  中国 广东 肇庆 电信
初级用户
★★
Credits 152
Posts 74
Joined 2005-12-01 23:06
20-year member
UID 46314
Status Offline
Floor 11 Posted 2007-01-01 05:20 ·  中国 江苏 苏州 中移铁通
初级用户
★★
Credits 144
Posts 66
Joined 2006-11-30 00:37
19-year member
UID 72121
Gender Male
Status Offline
Moderator's .bat > multiplication table.txt
~~~~N~ed
Floor 12 Posted 2007-01-01 05:44 ·  中国 广西 南宁 联通
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Originally posted by redtek at 2006-12-26 08:43:
......
Remembering the time when I recited this thing when I was a child, haha...

Often compared speed with others. At that time, it was generally finished reciting in about 25 seconds
Floor 13 Posted 2007-01-01 05:47 ·  中国 广东 广州 海珠区 电信
初级用户
Credits 142
Posts 18
Joined 2003-04-02 00:00
23-year member
UID 1355
Gender Male
Status Offline
It's almost the same as when I was learning C language! Haha!
Floor 14 Posted 2007-01-31 06:55 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Originally posted by zh159 at 2006-12-31 16:44:

Often compare speed with others. At that time, generally memorize it in about 25 seconds


Pretty fast~~~

Appreciate the multiplication table again~
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 15 Posted 2007-01-31 10:41 ·  中国 湖南 衡阳 电信
中级用户
★★
Credits 322
Posts 144
Joined 2007-01-10 13:00
19-year member
UID 76062
Gender Male
Status Offline
Learning
Forum Jump: