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中文網其他相關文章!