vendredi 26 avril 2019

How to sort counted(occurrence) numbers in increasing order?

I have given this question to create 50 random numbers from 1 to 15 and count how many times each occurred. I need to print them out in increasing order, but I couldn't. So far, I can only print out the numbers randomly and counter increasingly next to them. Any idea how I can print them out in order?

Thank you

INCLUDE Irvine32.inc
.data
blank byte " ",0

count byte 16 dup (0)
    dates dword 50 dup (?)
.code
main PROC 
call randomize
mov edx, offset blank
    mov edi,0   ;count index
mov ecx,50 
printnum:

    mov eax,15
    call randomRange    
    add eax,1
    call writedec
        mov dates[edi],eax;

        add edi,4;
    mov esi, eax
    inc count[esi]
        call writestring
        movzx eax,count[esi]
        call writedec
    call writestring
        mov eax,ecx

loop printnum

call crlf 

exit
main ENDP
end main




Aucun commentaire:

Enregistrer un commentaire