题目:已知数组A包含15个互不相等的整数,数组B中包含20个互不相等的整数。试编制一程序,把既在数组A中又在数组B中出现的整数存放在数组C中。

 

1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;Author:
3 ;comment: Blank
4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5 ;input code
6  
7  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 sta segment
9 dw 40h dup(?)
10 top label word
11 sta ends
12 data segment
13 a dw 2,1,6,8,7,12,32,30,68,77
14 b dw 9,3,7,23,30,77,88,80,79,41,14,22,12,63,31
15 c dw 10 dup(?)
16 data ends
17 code segment
18 assume cs:code,ds:data,ss:sta
19 start:
20 mov ax,sta
21 mov ss,ax
22 lea sp,top
23 mov ax,data
24 mov ds,ax
25
26 mov si,0
27 mov cx,10
28 mov bx,0
29 l00:
30 mov di,0
31
32 mov bp,15
33 mov ax,a[si]
34 l0:
35 cmp ax,b[di]
36 jne l1
37 jmp l3
38 l1:add di,2
39 dec bp
40 jnz l0
41 jmp l4
42 l3:mov c[bx],ax
43 add bx,2
44 l4:
45 add si,2
46 loop l00
47
48 mov ah,4ch
49 int 21h
50
51 code ends
52 end start

 

相关文章:

  • 2022-02-03
  • 2021-09-13
  • 2021-11-29
  • 2021-08-25
  • 2021-04-15
  • 2021-08-02
  • 2022-12-23
  • 2021-06-13
猜你喜欢
  • 2021-12-25
  • 2021-10-22
  • 2021-07-12
  • 2021-05-19
  • 2021-08-28
  • 2021-09-04
  • 2021-09-20
相关资源
相似解决方案