这个问题希望循环输入中的一个小数,直到只剩下一个数字。然而,一旦第一个循环达到0,它应该从第一个数字减1开始再次循环,如下所示,
Input decimal for loop: 4
Your loop result is: 4321 321 21 1或,
Input decimal for loop: 6
Your loop result is: 654321 54321 4321 321 21 1我现在有了,
DoWhileLoop:
DoWhileBody:
stdout.put( " I => ", I );
dec( I );
DoWhileTermination:
cmp( I, 0 );
jng DoWhileLoopDone;
jmp DoWhileLoopBody;
DoWhileLoopDone: 如果输入为4,则打印,
I => 4 I => 3 I => 2 I => 1我已经尝试了一个嵌套的for循环,以获得所需的连续性,但我不知道如何在不使computer...help崩溃的情况下增加它?
发布于 2013-03-30 09:44:20
解决了。我需要一个内部循环和第二个变量(J)来传递这个值。像这样(伪代码),
myWhileLoop:
myWhileLoopTermination:
cmp( Y, 0 );
jng WhileLoopDone;
myWhileLoopBody:
// Inner for loop goes in the body
innerForLoop:
InitializeinnerForLoop:
// Passing value of Y to Z
mov( Y, Z );
innerForLoopTerminationTest:
cmp( Z, 0 );
jng innerForLoopDone;
innerForLoopBody:
stdout.put( Z );
innerForLoopDecrement:
dec( Z );
jmp innerForLoopTerminationTest;
innerForLoopDone:
dec( Y );
jmp myWhileLoop;
myWhileLoopDone: https://stackoverflow.com/questions/15711949
复制相似问题