求助,统计学生成绩程序(利用分支和循环程序编写)
本帖最后由 tinymelody 于 2014-5-27 21:31 编辑题目:设有10个学生成绩分别为56,69,84,82,73,88,99,63,100和80试编写程序分别统计低于60分,60~69分,70~79分,80~89分,90~99分及100分的人数存放在S1,S2,S3,S4,S5,S6单元中(已经有部分参考代码了,就是不会写显示代码,程序用masm编译)
datarea segment
grade dw 56,69,84,82,73,88,99,63,100,80
s1 dw 0
s2 dw 0
s3 dw 0
s4 dw 0
s5 dw 0
s6 dw 0
datarea ends
prognam segment
main proc far
assume cs:prognam,ds:datarea
start:
;set up stack for return
push ds
sub ax,ax
push ax
;set DS register to current data segment
mov ax,datarea
mov ds,ax
;main part of program goes here
mov s1,0
mov s2,0
mov s3,0
mov s4,0
mov s5,0
mov s6,0
mov cx,10
mov bx,offset grade
compare:
mov ax,
cmp ax,60
jl one
cmp ax,70
jl two
cmp ax,80
jl three
cmp ax,90
jl four
cmp ax,100
jne five
inc s6
jmp short change_addr
five: inc s5
jmp short change_addr
four:inc s4
jmp short change_addr
three:inc s3
jmp short change_addr
two:inc s2
jmp short change_addr
one:inc s1
jmp short change_addr
change_addr:
add bx,2
loop compare
。。。。。。。
(这里是要写显示代码的,TAT不会写!)
(显示出S1=*,S2=*,S3=*,S4=*,S5=*,S^=* ——*表示人数)
main endp
prognam ends
end start
哪里来的题目 实验指导书上的QAQ,,, 求大神指教啊~~~:cry datarea segment
grade dw 56,69,84,82,73,88,99,63,100,80
s1 db 's1=0','$'
s2 db 's2=0','$'
s3 db 's3=0','$'
s4 db 's4=0','$'
s5 db 's5=0','$'
s6 db 's6=0','$'
datarea ends
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
prognam segment
main proc far
assume cs:prognam,ds:datarea
start:
;set up stack for return
push ds
sub ax,ax
push ax
;set DS register to current data segment
mov ax,datarea
mov ds,ax
;main part of program goes here
mov cx,10
mov bx,offset grade
compare:
mov ax,
cmp ax,60
jl one
cmp ax,70
jl two
cmp ax,80
jl three
cmp ax,90
jl four
cmp ax,100
jne five
inc byte ptr s6+3
jmp short change_addr
five: inc byte ptr s5+3
jmp short change_addr
four:inc byte ptr s4+3
jmp short change_addr
three:inc byte ptr s3+3
jmp short change_addr
two:inc byte ptr s2+3
jmp short change_addr
one:inc byte ptr s1+3
jmp short change_addr
change_addr:
add bx,2
loop compare
;输出
mov cx,6
lea dx,s1
print: mov ah,9
int 21h
add dx,7
loop print
mov ax,4c00h
int 21h
main endp
prognam ends
end start 只适用于当前题目 如果统计的个数超过9个 输出会错误
页:
[1]