9. Multiplication Table batch Edition

Source: Internet
Author: User

CopyCode The Code is as follows: @ echo off
: 9-9 multiplication table
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

: Another option. Use the tab key instead of the Space key for layout.
@ 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.
)
)
Pause

@ 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! & Amp; Set res = & amp; set I = 0
)
)
Pause

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.