debug 执行,查看运行结果。 06是及格的数量,02是不及格的数量,01是缺考数量。
dseg segment
scores db 87,94,76,52,71,83,-1,66,41
cnt equ $-scores ;成绩的个数
p db 0 ;>=60
q db 0 ;
r db 0 ;-1
dseg ends
cseg segment
assume cs:cseg, ds:dseg
start:
mov ax, dseg
mov ds, ax
lea si, scores
mov cx, cnt
s0:
mov al, [si]
cmp al, -1
je s3
cmp al, 60
jb s2
inc p ; >=60 的个数
jmp s4
s2:
inc q ;
jmp s4
s3:
inc r ; -1的个数
s4:
inc si
loop s0
; print p, q, r ,输出 结果,由于题目没有要,所以略过
mov ah, 4ch
int 21h
cseg ends
end start
假设学生成绩存在1000h开始的数据段中,段地址为2000h
code segment assume cs:code start: mov bx,00h mov dx,00h mov di,00h
mov ax,2000h
mov cx,100
mov ds,ax
mov si,1000h mov ax,01h next6:mov [si],ax inc ax inc si loop next6 mov cx,100 mov si,1000h
next4:cmp byte ptr[si],90
jg next
cmp byte ptr[si],60
jg next2
inc di
inc si
loop next4
jmp next5
next:inc bx
inc si
loop next4
next5:int 3h
next2:inc dx
inc si
loop next4
jmp next5
code ends
end start
Private Sub Form_Click()
Dim Score As Single, Sum As Single, N As Integer, Average As Single
Sum = 0
N = 0
Score = InputBox("请输入个同学的成绩", "成绩输入")
Do While Score -1
Sum = Sum + Score
N = N + 1
Score = InputBox("请输入第" & N + 1 & "个同学的成绩", "成绩输入")
Loop
Average = Sum / N
Print "平均成绩为:"; Average
End Sub
以上是使用汇编语言编写一个程序,通过统计以下成绩的及格、不及格和缺考人数的详细内容。更多信息请关注PHP中文网其他相关文章!