我想使用 smalltalk 代码以以下格式显示数字
1
1 2
1 2 3
1 2 3 4
我写了以下代码
| i j y k |
i :=1.
j :=1.
y:= ('y' at: 1 put: $ )out.
(i<=4)ifTrue: [
i to: 4 by:1 do:[:i |
(j<=i)ifTrue: [
j to: i by: 1 do:[:j |
( j print++y print)out.
]
]
]
]
当我执行上述程序时,它以下列格式显示数字
输出:
1 ' '
1 ' '
2 ' '
1 ' '
2 ' '
3 ' '
1 ' '
2 ' '
3 ' '
4 ' '
谁能帮助我以金字塔格式显示输出以及在 smalltalk 中获取新行的方法