用彙編語言編寫程序:分別統計下列成績中及格不及格和缺考的人數
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
有100個學生成績統計100 90 60 9060以下同學有幾個用匯編編寫的
假設學生成績存在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
用VB編寫一學生成績統計程序
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
以上就是使用彙編語言編寫一個程序,通過統計以下成績的及格、不及格和缺考人數的詳細內容,更多請關注本站其它相關文章!