下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、微機原理與接口技術題:一個學生的信息包括姓名、班級、學號、成績,其中成績需要精確到一位小數。試編寫程序實現以下功能:( 1)可以錄入學生成績(十進制形式) ;( 2)可以按要求(如學號或成績)進行排序顯示;( 3)可以統(tǒng)計平均成績;( 4)可以統(tǒng)計不及格、 6070、7080、8090、90100 各分數段的人數。;數組: name:存放姓名s_id:存放學號s_id1:存放排序后的學號number:原先排列序號number1:排序后的排列序號grade:學生成績grade1:經過排序后的學生成績data segmentsname db whq , yxm , dxq , yhh , fww
2、, gxj , ldx , lyh , zxt ,$ banji db2010211201,2010211202,2010211201,2010211205,2010211205,2 010211201,2010211203,2010211206,2010211202,$grade dw 234,356,876,856,874,902,738,839,927,$grade1 dw 9 dup(?)cishu dw 0cishu1 dw 0number db 1,2,3,4,5,6,7,8,9,$number1 db 1,2,3,4,5,6,7,8,9,$s_id db10211009,1021
3、1002,10211003,10211004,10211005,10211006,1 0211007,10211008,10211001,$s_id1 db 72 dup(?),$str1 db want to input grade? y/Y or n/N,$str2 db please input y/Y or n/N,$str3 db sort by student_id or grade? i/I or g/G.or press ENTER to jump this step,$str4 db please input i/I or g/G.or press ENTER to jump
4、 this step,$ str5 db show the average score? y/Y or n/N ,$str6 db count the number of students in different range? y/Y or n/N,$ str7 db press 1 to input grade, press 2 to sort, press 3 to show the averagescore,press 4 to count the number of students in different range, else, end the program,$string1
5、 db please input numbers or . :,$string2 db please input grade, press space to save the last grade and input the grade of the next student(9 students in total):,$string3 db out of range,reinput please!,$avera db the average score is:,$zancun dw 0aa db ?bb db ?cc db ?ddd db ?ee db ?zongde db there ar
6、e ,$bujige db students failed in the exam,$liushi db students get 6070,$qishi db students get 7080,$bashi db students get 8090,$jiushi db students get 90100,$xingming db sname,$class db banji,$xuehaoa db s_id,$chengji db grade,$data endscode segmentassume cs:code,ds:datastart:mov ax,datamov ds,axfir
7、st:mov dl,0ahmov ah,02int 21hmov dx,offset str1mov ah,9int 21hkaishi:mov ah,1int 21hcmp al,y;顯示成績輸入提示字符串jz shuru;輸入Y、y則輸入成績cmp al,Yjz shurucmp al,njz next2;輸入n、N 則下一步cmp al,Njz next2mov dl,0ahmov ah,02int 21hmov dx,offset str2mov ah,9int 21hjmp kaishishuru:mov dl,0ahmov ah,02int 21h;輸入其他字符則換行并顯示錯誤提示
8、字符串call inputnext2:mov dl,0ahmov ah,02int 21h;輸入成績mov dx,offset str3mov ah,9int 21hagain:mov ah,1int 21hcmp al,i;排序提示字符串jz id_rank;輸入i/I則按學號排序cmp al,Ijz id_rankcmp al,gjz g_rank;輸入g/G則按成績排序cmp al,Gjz g_rankcmp al,0dhjz next3mov dl,0ahmov ah,02int 21h;回車跳過本步驟mov dx,offset str4mov ah,9int 21hjmp again
9、id_rank:mov dl,0ahmov ah,02int 21hcall idrankjmp next3g_rank: mov dl,0ahmov ah,02int 21h;否則顯示錯誤提示字符串call granknext3:mov dl,0ahmov ah,02int 21hmov dx,offset str5mov ah,9int 21hagain1: mov ah,1int 21hcmp al,y;顯示統(tǒng)計平均成績提示字符串jz aver;輸入Y、y則統(tǒng)計平均成績cmp al,Yjz avercmp al,njz next4;輸入n、 N 則跳過本步cmp al,Njz next4
10、mov dl,0ahmov ah,02int 21hmov dx,offset str2mov ah,9;否則顯示錯誤提示字符串int 21hjmp again1zj1: jmp firstzj2: jmp next2zj3: jmp next3aver: mov dl,0ahmov ah,02int 21hcall averagenext4:mov dl,0ahmov ah,02int 21hmov dx,offset str6mov ah,9int 21hagain2: mov ah,1int 21hcmp al,y;顯示統(tǒng)計各分數段人數提示字符串jz next5;輸入Y、y則統(tǒng)計各分數段
11、人數cmp al,Yjz next5cmp al,njz done;輸入n、 N 則下一步cmp al,Njz donemov dl,0ahmov ah,02int 21hmov dx,offset str2mov ah,9int 21hjmp again2next5:mov dl,0ahmov ah,02int 21hcall countdone:;換行顯示錯誤提示字符串; mov dl,0ah; mov ah,02; int 21h; mov dx,offset str7 ;是否重新進行先前的步驟; mov ah,9; int 21h;again3:mov ah,1; int 21h; c
12、mp al,1; jz zj1; cmp al,2; jz zj2; cmp al,3; jz zj3; cmp al,4; jz next4; jmp lastlast: MOV AH,4CHINT 21Hinput proc near;輸入學生成績子程序mov dx,offset string2mov ah,9int 21hmov dl,0ahmov ah,02int 21hlea si,gradell:mov cx,45lz:mov bx,0one: mov ah,01hint 21hcmp al,0dh;回車結束jz donrcmp al, ;輸入空格鍵則指向下一個學生成績jz nex
13、t7cmp al,0;09 繼續(xù), 9 錯誤, 0 且不為 .也錯誤jnc next6cmp al,.jnz wrongjz lopnext6:cmp al,9ja wrongjmp shunext7:mov si,bxadd si,2mov bx,0jmp lopshu: sub al,30hcbwxchg ax,bxmov dx,10mul dxxchg ax,bxadd bx,axcmp bx,1000ja outoflop: loop onejmp donrwrong:mov dl,0ahmov ah,02int 21hmov dx,offset string1mov ah,9int
14、21hjmp lloutof:mov dl,0ah;出現錯誤則從頭輸入mov ah,02int 21hmov dx,offset string3mov ah,9int 21hmov dl,0ahmov ah,02int 21hjmp lldonr:retinput endpidrank proc nearmov cx,72lea si,s_idlea di,s_id1l2:mov ax,simov di,axadd si,1add di,1loop l2;把;按學號排序子程序 s_id 中的成績傳送給s_id1mov cx,8;冒泡排序PAI1:PUSH CX;保存外循環(huán)次數lea si,s_
15、id1mov di,0PAI2:MOV AX,SI+7CMP AX,SI+15JGE NEXT1;降序XCHG AX,SI+15;交換MOV SI+7,AXMOV AL,NUMBER1DI;交換名次XCHG AL,NUMBER1DI+1MOV NUMBER1DI,ALNEXT1:ADD SI,8;SI指向下一個學號INC DILOOP PAI2POP CXLOOP PAI1mov dl,0ahmov ah,02int 21hcall idxianshiretidrank endpgrank proc nearmov cx,9lea si,gradelea di,grade1l1:mov ax,
16、simov di,axadd si,2add di,2loop l1;按成績排序子程序;把 grade 中的成績傳送給grade1mov cx,8PAIXU1:;冒泡排序mov bx,cxlea si,grade1mov di,0PAIXU2:;保存外循環(huán)次數MOV AX,SICMP AX,SI+2JNC NEXT;降序XCHG AX,SI+2;交換MOV SI,AXMOV AL,NUMBERDI;交換名次XCHG AL,NUMBERDI+1MOV NUMBERDI,ALNEXT:ADD SI,2;SI指向下一個數INC DIdec bxjnz PAIXU2LOOP PAIXU1mov dl,
17、0ahmov ah,02int 21hcall gxianshiretgrank endpaverage proc near;顯示平均成績子程序mov dx,offset averamov ah,9int 21hlea si,grademov ax,simov cx,8jiafa: add ax,si+2add si,2loop jiafamov bx,9mov dx,0idiv bx;除以9,商存入AX,余數存入DXmov zancun,dxMOV CX,0MOV BX,10SHUCHU2:MOV DX,0INC CX;以下顯示商部分IDIV BX;商存入AX,余數存入DXPUSH DX;保
18、存余數CMP AX,0JNZ SHUCHU2dec cxSHUCHU3:POP AX;取出余數,放入AXADD AX,0030HMOV DL,ALMOV AH,2INT 21HLOOP SHUCHU3;輸出mov dl,.mov ah,2int 21hpop axmov cx,0;顯示 .mov cx,ax;小數部分先存入cxmov ax,zancun;取出除以9 之后的余數mov bl,10mul bl;乘以10 后再除以9mov bx,9mov dx,0idiv bx;商存入 AX,余數存入 DXcmp ax,5;小于 5 不變,否則 cx 加 1jc xianshiadd cx,1xia
19、nshi:mov dl,cladd dl,30hmov ah,2int 21hretaverage endpcount proc nearmov aa,0mov bb,0mov cc,0mov ddd,0mov ee,0mov cx,9lea si,grade;顯示各分數段人數子程序repet:mov ax,sicmp ax,600jc aa1cmp ax,700jc bb1cmp ax,800jc cc1cmp ax,900jc dd1jmp ee1aa1: inc aajmp wefbb1: inc bbjmp wefcc1: inc ccjmp wefdd1: inc dddjmp we
20、fee1: inc eejmp wefwef: add si,2loop repetmov dx,offset zongdemov ah,9int 21hadd aa,30hmov dl,aamov ah,02int 21hmov dx,offset bujigemov ah,9int 21hmov dl,0ahmov ah,2int 21hmov dx,offset zongdemov ah,9int 21hadd bb,30hmov dl,bbmov ah,02int 21hmov dx,offset liushimov ah,9int 21hmov dl,0ahmov ah,2int 2
21、1hmov dx,offset zongdemov ah,9int 21hadd cc,30hmov dl,ccmov ah,02int 21hmov dx,offset qishimov ah,9int 21hmov dl,0ahmov ah,2int 21hmov dx,offset zongdemov ah,9int 21hadd ddd,30hmov dl,dddmov ah,02int 21hmov dx,offset bashimov ah,9int 21hmov dl,0ahmov ah,2int 21hmov dx,offset zongdemov ah,9int 21hadd
22、 ee,30hmov dl,eemov ah,02int 21hmov dx,offset jiushimov ah,9int 21hmov dl,0ahmov ah,2int 21hretcount endpgxianshi proc nearmov dx,offset xingmingmov ah,9int 21hmov cx,3konggea:mov dl, mov ah,2int 21hloop konggeamov dx,offset classmov ah,9int 21hmov cx,6konggeb:mov dl, mov ah,2int 21hloop konggeb;將進行
23、按成績排序后的學生信息依次顯示mov dx,offset xuehaoamov ah,9int 21hmov cx,3kongge1:mov dl, mov ah,2int 21hloop kongge1mov dx,offset chengjimov ah,9int 21hmov dl,0ahmov ah,2int 21hmov cx,9mov di,0paixuxianshi:push cxmov bx,0mov cx,0ming:mov ax,0mov al,numberdidec almov bl,5mul bllea si,snameadd si,axmov cx,5let0: mo
24、v ah,2mov dl,siint 21hinc siloop let0mov ah,2mov dl, int 21hban: mov ax,0mov al,numberdidec almov bl,10mul bllea si,banjiadd si,axmov cx,10let1: mov ah,2mov dl,siint 21hinc siloop let1mov ah,2mov dl, int 21hjmp xuehaozj4: loop paixuxianshijmp chuquxuehao: mov ax,0mov al,numberdidec almov bl,8mul bll
25、ea si,s_idadd si,axmov cx,8let2: mov ah,2mov dl,siint 21hinc siloop let2mov ah,2mov dl, int 21hcheng:mov ax,0mov al,numberdidec almov bl,2mul bllea si,gradeadd si,axmov ax,simov cx,0mov bx,10shuc2:mov dx,0inc cxidiv bxpush dxcmp ax,0jnz shuc2dec cxshuc3:pop axadd ax,0030hmov dl,almov ah,2int 21hloop
26、 shuc3mov dl,.mov ah,2int 21hpop axadd ax,0030hmov dl,almov ah,2int 21hmov dl,0ahmov ah,2int 21hinc dipop cxjmp zj4; loop paixuxianshichuqu:retgxianshi endpidxianshi proc nearmov dx,offset xingmingmov ah,9int 21hmov dl,mov ah,2int 21hmov dx,offset class;將進行按成績排序后的學生信息依次顯示mov ah,9int 21hmov dl,mov ah,2int 21hmov dx,offset xuehaoamov ah,9int 21hmov cx,3kongge3:mov dl, mov ah,2int 21hloop kongge3mov dx,offset chengjimov ah,9int 21hmov dl,0ahmov ah,2int 21hmov cx,9mov di,0paixu
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年云計算服務定制購銷合同
- 2024年產品代理合同:制造商授權代理商銷售產品
- 2024年大型水上樂園建設與運營合同
- 云南省文山壯族苗族自治州(2024年-2025年小學五年級語文)人教版小升初模擬(上學期)試卷及答案
- 齒輪泵課課程設計
- pYEEI-生命科學試劑-MCE
- 2024年監(jiān)理服務專項協議范本
- 環(huán)境教育的哲言
- 暑假社會實踐調查報告
- 2024年房產租賃居間協議模板
- 大工電機與拖動實驗報告一
- 小學二年級上冊語文部編版課件 紙船和風箏(生字講解)
- 紅色消防安全知識宣傳培訓課件PPT模板
- 果蔬機械冷藏課件2
- 拼音復習-拼音轉盤課件
- 項目進度管理培訓(-)課件
- 高考語文 如何讀懂詩歌 課件(32張PPT)
- 中壓交聯電纜電纜正、負和零序計算
- 3C戰(zhàn)略三角模型
- 高標準農田建設示范工程質量管理體系與措施
- 學生頂崗實習安全教育課件
評論
0/150
提交評論