;;;;;;;;;;;;;;;;;二叉树的遍历 .model small .stack 64 .data ;-------------------------------------------------------------------------------------------------------------------------------- binary db 63 dup (0,0,0) hey1 db 'Please input the root of the binary:',0dh,0ah,'$' hey2 db 0dh,0ah,'Does ',27h,'$' hey3 db 27h,' have a leftchild?(If it no leftchild,please press ENTER)',0dh,0ah,'$' hey4 db 27h,' have a rightchild?(If it no rightchild,please key in ENTER)',0dh,0ah,'$' hey5 db 'The first root traversing:',0dh,0ah,'$' hey6 db 'The middle root traversing:',0dh,0ah,'$' hey7 db 'The last root traversing:',0dh,0ah,'$' hey8 db 0dh,0ah,'$' hey9 db 0dh,0ah,'The input is over!','$' hey10 db 0dh,0ah,'Pree anykey to continue,ESC to finish...',0dh,0ah,'$' ;--------------------------------------------------------------------------------------------------------------------------------- .code main proc far ;the main procedure mov ax,seg hey1 mov ds,ax jmp loop2 start1:mov cx,189 mov bx,offset binary mov dx,0 loop1:mov byte ptr[bx],dl inc bx dec cx cmp cx,0 jnz loop1 loop2:mov dx,offset hey1 mov ax,0900h int 21h mov si,offset binary sub cx,cx mov ax,0100H int 21h cmp al,0dh jz exit1 add cx,3 call Inroot call firstr mov ax,0900h mov dx,offset hey8 int 21h mov dx,offset hey6 int 21h mov si,offset binary mov cx,3 call midr mov dx,offset hey8 int 21h mov dx,offset hey7 int 21h mov si,offset binary mov cx,3 call lastr mov dx,offset hey10 int 21h mov ax,0100h int 21h cmp al,1bh jnz start1 exit1: mov ax, 4c00h int 21h main endp

评论