您好,欢迎访问三七文档
微机原理与接口技术题:一个学生的信息包括姓名、班级、学号、成绩,其中成绩需要精确到一位小数。试编写程序实现以下功能:(1)可以录入学生成绩(十进制形式);(2)可以按要求(如学号或成绩)进行排序显示;(3)可以统计平均成绩;(4)可以统计不及格、60~70、70~80、80~90、90~100各分数段的人数。;数组:name:存放姓名s_id:存放学号s_id1:存放排序后的学号number:原先排列序号number1:排序后的排列序号grade:学生成绩grade1:经过排序后的学生成绩datasegmentsnamedb'whq','yxm','dxq','yhh','fww','gxj','ldx','lyh','zxt','$'banjidb'2010211201','2010211202','2010211201','2010211205','2010211205','2010211201','2010211203','2010211206','2010211202','$'gradedw234,356,876,856,874,902,738,839,927,'$'grade1dw9dup(?)cishudw0cishu1dw0numberdb1,2,3,4,5,6,7,8,9,'$'number1db1,2,3,4,5,6,7,8,9,'$'s_iddb'10211009','10211002','10211003','10211004','10211005','10211006','10211007','10211008','10211001','$'s_id1db72dup(?),'$'str1db'wanttoinputgrade?y/Yorn/N','$'str2db'pleaseinputy/Yorn/N','$'str3db'sortbystudent_idorgrade?i/Iorg/G.orpressENTERtojumpthisstep','$'str4db'pleaseinputi/Iorg/G.orpressENTERtojumpthisstep','$'str5db'showtheaveragescore?y/Yorn/N','$'str6db'countthenumberofstudentsindifferentrange?y/Yorn/N','$'str7db'press1toinputgrade,press2tosort,press3toshowtheaveragescore,press4tocountthenumberofstudentsindifferentrange,else,endtheprogram','$'string1db'pleaseinputnumbersor.:','$'string2db'pleaseinputgrade,pressspacetosavethelastgradeandinputthegradeofthenextstudent(9studentsintotal):','$'string3db'outofrange,reinputplease!','$'averadb'theaveragescoreis:','$'zancundw0aadb?bbdb?ccdb?ddddb?eedb?zongdedb'thereare','$'bujigedb'studentsfailedintheexam','$'liushidb'studentsget60~70','$'qishidb'studentsget70~80','$'bashidb'studentsget80~90','$'jiushidb'studentsget90~100','$'xingmingdb'sname','$'classdb'banji','$'xuehaoadb's_id','$'chengjidb'grade','$'dataendscodesegmentassumecs:code,ds:datastart:movax,datamovds,axfirst:movdl,0ahmovah,02int21hmovdx,offsetstr1;显示成绩输入提示字符串movah,9int21hkaishi:movah,1int21hcmpal,'y'jzshuru;输入Y、y则输入成绩cmpal,'Y'jzshurucmpal,'n'jznext2;输入n、N则下一步cmpal,'N'jznext2movdl,0ah;输入其他字符则换行并显示错误提示字符串movah,02int21hmovdx,offsetstr2movah,9int21hjmpkaishishuru:movdl,0ahmovah,02int21hcallinput;输入成绩next2:movdl,0ahmovah,02int21hmovdx,offsetstr3;排序提示字符串movah,9int21hagain:movah,1int21hcmpal,'i'jzid_rank;输入i/I则按学号排序cmpal,'I'jzid_rankcmpal,'g'jzg_rank;输入g/G则按成绩排序cmpal,'G'jzg_rankcmpal,0dh;回车跳过本步骤jznext3movdl,0ahmovah,02int21hmovdx,offsetstr4;否则显示错误提示字符串movah,9int21hjmpagainid_rank:movdl,0ahmovah,02int21hcallidrankjmpnext3g_rank:movdl,0ahmovah,02int21hcallgranknext3:movdl,0ahmovah,02int21hmovdx,offsetstr5;显示统计平均成绩提示字符串movah,9int21hagain1:movah,1int21hcmpal,'y'jzaver;输入Y、y则统计平均成绩cmpal,'Y'jzavercmpal,'n'jznext4;输入n、N则跳过本步cmpal,'N'jznext4movdl,0ahmovah,02int21hmovdx,offsetstr2;否则显示错误提示字符串movah,9int21hjmpagain1zj1:jmpfirstzj2:jmpnext2zj3:jmpnext3aver:movdl,0ahmovah,02int21hcallaveragenext4:movdl,0ahmovah,02int21hmovdx,offsetstr6;显示统计各分数段人数提示字符串movah,9int21hagain2:movah,1int21hcmpal,'y'jznext5;输入Y、y则统计各分数段人数cmpal,'Y'jznext5cmpal,'n'jzdone;输入n、N则下一步cmpal,'N'jzdonemovdl,0ah;换行显示错误提示字符串movah,02int21hmovdx,offsetstr2movah,9int21hjmpagain2next5:movdl,0ahmovah,02int21hcallcountdone:;movdl,0ah;movah,02;int21h;movdx,offsetstr7;是否重新进行先前的步骤;movah,9;int21h;again3:movah,1;int21h;cmpal,'1';jzzj1;cmpal,'2';jzzj2;cmpal,'3';jzzj3;cmpal,'4';jznext4;jmplastlast:MOVAH,4CHINT21Hinputprocnear;输入学生成绩子程序movdx,offsetstring2movah,9int21hmovdl,0ahmovah,02int21hleasi,gradell:movcx,45lz:movbx,0one:movah,01hint21hcmpal,0dh;回车结束jzdonrcmpal,'';输入空格键则指向下一个学生成绩jznext7cmpal,'0';0~9继续,9错误,0且不为‘.'也错误jncnext6cmpal,'.'jnzwrongjzlopnext6:cmpal,'9'jawrongjmpshunext7:mov[si],bxaddsi,2movbx,0jmplopshu:subal,30hcbwxchgax,bxmovdx,10muldxxchgax,bxaddbx,axcmpbx,1000jaoutoflop:looponejmpdonrwrong:movdl,0ah;出现错误则从头输入movah,02int21hmovdx,offsetstring1movah,9int21hjmplloutof:movdl,0ahmovah,02int21hmovdx,offsetstring3movah,9int21hmovdl,0ahmovah,02int21hjmplldonr:retinputendpidrankprocnear;按学号排序子程序movcx,72;把s_id中的成绩传送给s_id1leasi,s_idleadi,s_id1l2:movax,[si]mov[di],axaddsi,1adddi,1loopl2movcx,8;冒泡排序PAI1:PUSHCX;保存外循环次数leasi,s_id1movdi,0PAI2:MOVAX,[SI+7]CMPAX,[SI+15]JGENEXT1;降序XCHGAX,[SI+15];交换MOV[SI+7],AXMOVAL,NUMBER1[DI];交换名次XCHGAL,NUMBER1[DI+1]MOVNUMBER1[DI],ALNEXT1:ADDSI,8;SI指向下一个学号INCDILOOPPAI2POPCXLOOPPAI1movdl,0ahmovah,02int21hcallidxianshiretidrankendpgrankprocnear;按成绩排序子程序movcx,9;把grade中的成绩传送给grade1leasi,gradeleadi,grade1l1:movax,[si]mov[di],axaddsi,2adddi,2loopl1movcx,8;冒泡排序PAIXU1:movbx,cx;保存外循环次数leasi,grade1movdi,0PAIXU2:MOVAX,[SI]CMPAX,[SI+2]JNCNEXT;降序XCHGAX,[SI+2];交换MOV[SI],AXMOVAL,NUMBER[DI];交换名次XCHGAL,NUMBER[DI+1]MOVNUMBER[DI],ALNEXT:ADDSI,2;SI指向下一个数INCDIdecbxjnzPAIXU2LOOPPAIXU1movdl,0ahmovah,02int21hcallgxianshiretgrankendpaverageprocnear;显示平均成绩子程序movdx,offsetaveramovah,9int21hleasi,grademovax,[si]movcx,8jiafa:addax,[si+2]addsi,2loopjiafamovbx,9movdx,0idivbx;除以9,商存入AX,余数存入DXmovzancun,dxMOVCX,0;以下显示商部分MOVBX,10SHUCHU2:MOVDX,0INCCXIDIVBX;商存入AX,余数存入DXPUSHDX;保存余数CMPAX,0JNZSHUCHU2deccxSHUCHU3:POPAX;取出余数,放入AXADDAX,0030HMOVDL,AL;输出MOVAH,2INT21HLOOPSHUCHU3movdl,'.';显示'.'movah,2int21hpopaxmovcx,0movcx,ax;小数部分先存入cxmovax,zancun;取出除以9之后的余数movbl,10mulbl;乘以10后再除以9movbx,9movdx,0idi
本文标题:汇编程序题
链接地址:https://www.777doc.com/doc-3297339 .html