Floyd's triangle: Difference between revisions
→{{header|Batch File}}: Fixed
(Floyd's triangle en QBasic and Yabasic) |
Simple9371 (talk | contribs) (→{{header|Batch File}}: Fixed) |
||
Line 1,637:
=={{header|Batch File}}==
{{trans|QBasic}}
<lang dos>:: Floyd's triangle Task from Rosetta Code
:: Batch File Implementation
@echo off
rem main thing
echo.▼
exit /b▼
setlocal enabledelayedexpansion
call :floydtriangle 5
set startn=1▼
call :floydtriangle 14
▲exit /b 0
:floydtriangle
for /l %%i in (1,1,%iterations%) do (▼
for /l %%j in (!startn!,1,!endn!) do (▼
set lastnum=%%j▼
set /a
rem count number of digits of whole number trick
)▼
rem source: https://stackoverflow.com/a/45472269
set /a "Log=1!lastRowNum:~1!-!lastRowNum:~1!-0"
)
echo(Output for %fila%
rem count number of digits of whole number trick
set /a "Log=1!thisNum:~1!-!thisNum:~1!-0"
set /a "thisNumColum=!Log:0=+1!"
▲for /l %%i in (1,1,%iterations%) do (
rem handle spacing
▲ set "line="
set "space= "
set /a "
for /l %%s in (1,1,!extra!) do set "space=!space! "
rem append current number to printLine
set /a "thisNum=!thisNum!+1"
▲ )
echo(!printLine!
▲ set /a startn=%%j+1
)
goto :EOF</lang>▼
▲</lang>
{{out}}
<pre>Output for 5
1
2 3
Line 1,700 ⟶ 1,685:
11 12 13 14 15
Output for 14
2
4
11 12 13 14 15
56 57
67 68
79 80
92 93 94 95 96 97 98 99 100 101 102 103 104 105</pre>
=={{header|BCPL}}==
|