稍微改一下要排的數就行了CRLF MACRO MOV DL,0DH MOV AH,2 INT 21H MOV DL,0AH MOV AH,2 INT 21HENDMDATA SEGMENT N EQU 10 W DW 8,41,32,54,25,16,37,22,18,46DATA ENDSCODE SEGMENT ASSUME CS: CODE, DS: DATABEGIN: MOV AX, DATA MOV DS, AX MOV CX, N DEC CXLOOP1:MOV DI,CX MOV BX, 0 LOOP2:MOV AX,W[BX] CMP AX,W[BX+2] JGE NEXT XCHG AX, W[BX+2] MOV W[BX], AXNEXT:ADD BX,2 LOOP LOOP2 MOV CX,DI LOOP LOOP1 XOR BX,BX MOV CX,ND: MOV AX, W[BX] MOV DL,10 DIV DL MOV DH,AH MOV DL,AL ADD DL,30H MOV AH,2 INT 21H MOV DL,DH ADD DL,30H MOV AH,2 INT 21H ADD BX,2 CRLF LOOP D MOV AH,4CH INT 21HCODE ENDSEND BEGIN
稍微改一下要排的數就行了CRLF MACRO MOV DL,0DH MOV AH,2 INT 21H MOV DL,0AH MOV AH,2 INT 21HENDMDATA SEGMENT N EQU 10 W DW 8,41,32,54,25,16,37,22,18,46DATA ENDSCODE SEGMENT ASSUME CS: CODE, DS: DATABEGIN: MOV AX, DATA MOV DS, AX MOV CX, N DEC CXLOOP1:MOV DI,CX MOV BX, 0 LOOP2:MOV AX,W[BX] CMP AX,W[BX+2] JGE NEXT XCHG AX, W[BX+2] MOV W[BX], AXNEXT:ADD BX,2 LOOP LOOP2 MOV CX,DI LOOP LOOP1 XOR BX,BX MOV CX,ND: MOV AX, W[BX] MOV DL,10 DIV DL MOV DH,AH MOV DL,AL ADD DL,30H MOV AH,2 INT 21H MOV DL,DH ADD DL,30H MOV AH,2 INT 21H ADD BX,2 CRLF LOOP D MOV AH,4CH INT 21HCODE ENDSEND BEGIN