Try to replicate this pyramid using only loop structures.

 

1
232
34543
4567654
567898765
67890109876
7890123210987
890123454321098
90123456765432109
0123456789876543210

If i got rid of the fact of it only being digits, and i could use numbers like 10 and 11..... I can get the pyramid to work fine. But then again the bottom layer is very wide cause of the double digit numbers. my loop structures fail when i try and implement the digit rule. :(


program cmdline; 


#include ("stdlib.hhf")
static

begin cmdline;
console.cls();
mov(20,eax);
mov(1,ebx);
mov(3,ecx);
again:
cmp(eax, 0);
jle NoMoreX;
cmp(ebx,10);
jg NoMoreY;
console.gotoxy(eax,ebx);
stdout.put((type int32 ebx));
mov(ebx,edx);
cmp(edx,1);
je FirstException;

WhyNot:
cmp(edx,ecx);
je LoopDown;
cmp(ecx,10);
jge DeDigit1;
cmp(edx,10);
je DeDigit;
inc(edx);
stdout.put((type int32 edx));
jmp WhyNot;
LoopDown:
cmp(edx,ebx);
je finishedwiththat;
cmp(edx,10);
jge DeDigit2;
cmp(ecx,10);
jge DeDigit3;
dec(edx);
stdout.put((type int32 edx));
jmp LoopDown;
DeDigit:
sub(10,edx);
stdout.put((type int32 edx));
jmp WhyNot;
DeDigit1:
sub(10,ecx);
stdout.put((type int32 ecx));
jmp WhyNot;
DeDigit2:
sub(10,edx);
stdout.put((type int32 edx));
jmp LoopDown;
DeDigit3:
sub(10,ecx);
stdout.put((type int32 ecx));
jmp LoopDown;
finishedwiththat:
inc(ebx);
dec(eax);
add(2,ecx);
jmp again;
jmp again;
FirstException:
inc(ebx);
dec(eax);
jmp again;
NoMoreY:
NoMoreX:


end cmdline;
Posted on 2003-12-07 22:36:29 by WhiteDwarf