99 multiplication table batch version

Time:2021-1-1

99 multiplication table batch version

Copy codeThe code is as follows:
@echo off
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 way is to use the tab key instead of the space bar for typesetting
@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!&set res=& set i=0
)
)
pause

Recommended Today

Review of SQL Sever basic command

catalogue preface Installation of virtual machine Commands and operations Basic command syntax Case sensitive SQL keyword and function name Column and Index Names alias Too long to see? Space Database connection Connection of SSMS Connection of command line Database operation establish delete constraint integrity constraint Common constraints NOT NULL UNIQUE PRIMARY KEY FOREIGN KEY DEFAULT […]