学生成绩档案管理系统
一、课程设计题目
学生成绩档案管理系统设计
二、课程设计内容与要求
用汇编语言编写程序,设计一个学生成绩档案管理系统。要求
该系统具有如下 6 个的基本功能:1 输入;2 显示;3 查找;4 修改;
5 排序;6 退出。界面以菜单形式显示, 每个学生的信息包含:学
号、姓名、成绩,排序按照成绩进行
三、算法描述与实现(程序流程图/原理图)
针对这个成绩档案管理系统定义的功能,我们采用了数组来实现,
定义了三个数组 sno、sname、grade 来分别保存学号、姓名和成绩,
定义了一个数组 count 来保存输入的 sname 的长度以此来实现字符型
的姓名的输出。
1.输入:要求先输入要输入的记录的条数,然后就输入学号、姓名
和成绩,其中学号和成绩是数字型的,姓名是字符型的可以输入任意
个大小,因为我们设置了一个数组 count 来保存输入的字符的个数,
以便下一次输入时上次输入的记录不被覆盖;
2.显示:分为两个部分,查看全部的学生信息和查看需要补考的学
生信息,显示姓名的时候需要把前面已经输出的学生姓名的字符个数
学生成绩档案管理系统
1
加起来就是要输出的下一个姓名的地址,就是根据这种方法把姓名输
出出来的;
3.查找:我们设计的是两种查找方法,按学号查找和按成绩查找,
输入的学号与数组 sno 的元素比较,相等的话就输出该条记录,否则
继续查找直到结束,如果没有找到就提示“抱歉,没有要查找的学
生!”;输入的成绩与数组 grade 的元素比较,相等的话就输出该条记
录,否则继续查找直到结束,同样如果没有找到就提示“抱歉,没有
要查找的学生!”;
4.修改:既可以修改学号又可以修改成绩,要求用户先输入要修改
的学生的学号,然后再输入要修改的新成绩或学号,用输入的数据把
原数据覆盖后再输出;
5.排序:包括按学号排序和按成绩排序两种,采用冒泡排序法,借
鉴了课设指导书上的冒泡排序程序;
6.退出:返回 DOS
系统流程图:
学生成绩档案管理系统
2
开始
主菜单
输入
输出
查找
修改
排序
退出
结束
四、程序实现(完整的程序清单)
include io32.inc
dword 100 dup(100)
;---------------------------------------------------------------
.data
sno
sname byte 100 dup(100)
grade dword 100 dup(100)
count dword 100 dup(100)
msg1 byte'1.输入',0
msg2 byte'2.显示',0
msg3 byte'3.查找',0
msg4 byte'4.修改',0
msg5 byte'5.排序',0
msg6 byte'6.退出',0
msg7 byte'请输入您的选择:1-->6',0
msg8 byte'错误,系统将返回主菜单:',0
msg9 byte'请输入您要录入的记录个数:',0
msg10 byte'请输入记录,学号(数字),姓名(字符串),成绩(数字):',0
学生成绩档案管理系统
3
msg11 byte '请输入要查找的同学学号:',0
msg12 byte '抱歉,没有要查找的学生!',0
msg13 byte '请输入要修改的学生学号:',0
msg14 byte '抱歉,没有要修改的学生!',0
msg15 byte '请输入要修改的新成绩/学号:',0
msg16 byte '修改后的学生学号和成绩为:',0
msg17 byte '1.按学号排序;2.按成绩排序;请输入您的选择 1-->2:',0
msg18 byte '1.按学号查找;2.按成绩查找;请输入您的选择 1-->2:',0
msg19 byte '请输入要查找的成绩:',0
msg20 byte '1.修改学号;2.修改成绩;请输入您的选择 1-->2:',0
msg21 byte '所查找的学生学号和成绩为:',0
msg22 byte '1.查看全部学生的信息;2.查看补考学生的学号;请输入您的选择
1-->2:',0
msg23 byte '所要查看的补考学生学号和成绩为:',0
msg24 byte '----------排序结果------------',0ah,0dh
byte '学号 成绩',0ah,0dh,0
msg25 byte '所要查看的补考学生学号和成绩为:',0 ah,0dh
n dword ?
x dword ?
;----------------------------------------------------------------
.code
main proc
mov eax,offset msg25
call dispmsg
again:
ebx,0
mov
mov eax,offset msg1
call dispmsg
call dispcrlf
mov eax,offset msg2
call dispmsg
call dispcrlf
mov eax,offset msg3
call dispmsg
call dispcrlf
mov eax,offset msg4
call dispmsg
call dispcrlf
mov eax,offset msg5
call dispmsg
call dispcrlf
mov eax,offset msg6
call dispmsg
call dispcrlf
学生成绩档案管理系统
4
mov eax,offset msg7
call dispmsg
call dispcrlf
;-------------------------------------------------------------
;跳到输入
;跳到显示
n,eax
n,1
call readuid
mov
cmp
je input1
cmp n,2
je disp1
cmp n,3
je search1
cmp n,4
je edit1
cmp n,5
je sort1
cmp n,6
je done
mov eax,offset msg8
call dispmsg
jmp again
;跳到排序
;跳到退出
;跳到查找
;跳到修改
;--------------------------------------------------------------
input1:
;输入
x,eax
mov eax,offset msg9
call dispmsg
call dispcrlf
call readuid
mov
mov eax,offset msg10
call dispmsg
call dispcrlf
mov
mov
eax,offset sname
edx,eax
input2:
sno[ebx*(type sno)],eax
cmp ebx,x
jz
again
call readuid
mov
call dispcrlf
add edx,1
mov eax,edx
call readmsg
mov count[ebx*(type sno)],eax
add edx,count[ebx*(type sno)]
;输入姓名
学生成绩档案管理系统
5
grade[ebx*(type grade)],eax
call dispcrlf
call readuid
mov
call dispcrlf
inc
jmp
ebx
input2
;--------------------------------------------------------------
disp1:
;输出
mov eax,offset msg22
call dispmsg
call dispcrlf
eax,offset sname
mov
mov
edx,eax
call readuid
n,eax
mov
cmp
n,1
je disp2
cmp n,2
je disp3
mov
mov
eax,offset sname
edx,eax
;跳到查看全部
;跳到查看补考信息
disp2:
;显示姓名
mov eax,sno[ebx*(type sno)]
call dispuid
mov al,20h
call dispc
add edx,1
mov eax,edx
call dispmsg
add edx,count[ebx*(type sno)]
mov eax,' '
call dispc
mov eax,grade[ebx*(type grade)]
call dispuid
mov al,20h
call dispc
call dispcrlf
inc ebx
cmp ebx,x
jae again
jmp disp2
disp3:
eax,offset msg23
mov
call dispmsg
学生成绩档案管理系统
6
call dispcrlf
disp4:
disp5:
cmp
jz
cmp
jb
inc
jmp
ebx,x
again
grade[ebx*(type grade)],60
disp5
ebx
disp4
mov eax,sno[ebx*(type sno)]
call dispuid
call dispcrlf
inc
jmp
ebx
disp4
;---------------------------------------------------------------
search1:
;查找
mov eax,offset msg18
call dispmsg
call dispcrlf
call readuid
mov
cmp
je search2
cmp n,2
je search3
mov eax,offset msg11
n,eax
n,1
;跳到按学号查找
;跳到按成绩查找
;按学号查找
call dispmsg
call dispcrlf
call readuid
mov esi,eax
cmp x,ebx
jbe disperror
cmp esi,sno[ebx*(type sno)]
jz dispok
inc edx
inc ebx
jmp lp
search2:
lp:
disperror:
mov eax,offset msg12
call dispmsg
call dispcrlf
jmp again
dispok:
mov eax,offset msg21
学生成绩档案管理系统
7
call dispmsg
call dispcrlf
mov eax,sno[ebx*(type sno)]
call dispuid
mov al,20h
call dispc
mov eax,grade[ebx*(type grade)]
call dispuid
call dispcrlf
jmp again
search3:
;按成绩查找
lp2:
mov eax,offset msg19
call dispmsg
call dispcrlf
call readuid
mov esi,eax
cmp x,ebx
be disperror2
cmp esi,grade[ebx*(type sno)]
jz dispok2
inc edx
inc ebx
jmp lp2
disperror2:
mov eax,offset msg12
call dispmsg
call dispcrlf
jmp again
dispok2:
mov eax,offset msg21
call dispmsg
call dispcrlf
mov eax,sno[ebx*(type sno)]
call dispuid
mov al,20h
call dispc
mov eax,grade[ebx*(type grade)]
call dispuid
call dispcrlf
jmp again
;---------------------------------------------------------------
edit1:
;修改
mov eax,offset msg13
call dispmsg