如果您有两个单元格,每个单元格的值为0到9,则可以只将一个单元格添加到另一个单元格中.假设您有两个单元格A和B. A位于位置0而B位于位置1.您可以像这样将B添加到A(假设指针从A开始).我将A设置为4,B设置为8,然后将B添加到A:
setting A and B
++++>++++++++
remember the pointer is at B now so we can add B to A like this
[<+>-]
and now the pointer is still at B but B contains 0 and A contains 12
Run Code Online (Sandbox Code Playgroud)
如果您希望用户输入这些单个数字,请记住,当您使用字符时,字符的ASCII代码将放在当前单元格中.所以你首先需要从数字中减去48(48是字符'0'的ASCII代码).这是一个用键盘中的两个字符填充A和B的示例(我将假设用户只按任意数字键,而不是字母或符号)
Pointer starts at A so we have the user press a number key
,
we then subtract 48 from it so that it contains the actual value
------------------------------------------------
we move to B and do the same
>,------------------------------------------------
from here on it's the same as the last example
[<+>-]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
957 次 |
| 最近记录: |