News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Number triangle

Started by TmX, November 07, 2010, 03:16:38 PM

Previous topic - Next topic

TmX

This the output I want:
Quote
3
3 4
3 4 5
3 4 5 6
3 4 5 6 7

My code:

program triangle;
#include("stdlib.hhf")

begin triangle;
mov(7, edx);
for (mov (3, ecx); ecx <= edx; inc(ecx)) do
for (mov (ecx, eax); eax <= ecx; inc(eax)) do
stdout.put((type uns32 eax)," ");
endfor;
stdout.put(nl);
endfor;
end triangle;


The output is:
Quote
3
4
5
6
7

Hmm what is wrong here?
Quote

Emil_halim


note well , the second for-endfor loop will always execute only one time.

here is the correct code

program triangle;
#include("stdlib.hhf")

begin triangle;
mov(7, edx);
for (mov (3, ecx); ecx <= edx; inc(ecx)) do
for (mov (3, eax); eax <= ecx; inc(eax)) do
stdout.put((type uns32 eax)," ");
endfor;
stdout.put(nl);
endfor;
end triangle;



TmX

Ah, I didn't notice that.  :red

Thanks!