微機(jī)編程實(shí)習(xí)報(bào)告?zhèn)€人版_第1頁
微機(jī)編程實(shí)習(xí)報(bào)告?zhèn)€人版_第2頁
微機(jī)編程實(shí)習(xí)報(bào)告?zhèn)€人版_第3頁
微機(jī)編程實(shí)習(xí)報(bào)告?zhèn)€人版_第4頁
微機(jī)編程實(shí)習(xí)報(bào)告?zhèn)€人版_第5頁
已閱讀5頁,還剩7頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上精選優(yōu)質(zhì)文檔-傾情為你奉上專心-專注-專業(yè)專心-專注-專業(yè)精選優(yōu)質(zhì)文檔-傾情為你奉上專心-專注-專業(yè)編程實(shí)習(xí)實(shí)習(xí)報(bào)告學(xué) 號: .班 級: .學(xué)生姓名: .起始日期: .完成日期: .任務(wù)要求用字符串指針實(shí)現(xiàn)學(xué)生成績管理系統(tǒng),具體完成的功能見可執(zhí)行程序Student.exe。完成函數(shù)void DeleteStudent(char* students,int* marks);void SortClass(char* students,int* marks);void ShowClass(char* students,int* marks);void EditMarks(c

2、har* students,int* marks);二、詳細(xì)設(shè)計(jì)(分析各函數(shù)的功能,設(shè)計(jì)各函數(shù)的處理過程及其流程圖)void InsertStudent(char* students,int* marks);插入學(xué)生姓名 基本想法:先讀取學(xué)生姓名,判斷指針是否為空,為空則建立內(nèi)存。否則再開拓新的內(nèi)存空間,然后將讀取的學(xué)生與名單一一比較,若相同,則顯示已存在該學(xué)生,若沒有,則開拓內(nèi)存給新到的學(xué)生,并對名單進(jìn)行排序。void DeleteStudent(char* students,int* marks);刪除學(xué)生信息基本想法:先讀取要刪除的學(xué)生姓名,將讀入的學(xué)生姓名與已存在的學(xué)生進(jìn)行比較,如相同

3、,記住該學(xué)生所在位置,判斷該學(xué)生下一個是否為空,若為空,就可以直接把該學(xué)生內(nèi)存釋放掉。若不是,則用一個while 將后面的所有學(xué)生向前移一位 直到NULL,再釋放最后的內(nèi)存,最后再釋放學(xué)生姓名的那個內(nèi)存void SortClass(char* students,int* marks); 排序 基本想法:采用冒泡法來進(jìn)行排序。N次排序 先進(jìn)行n-1次比大小,找到最小的,與第一個交換,再進(jìn)行n-2次。void ShowClass(char* students,int* marks); 顯示所有學(xué)生信息基本想法:直接用printf 輸出,void EditMarks(char* students,i

4、nt* marks); 編輯學(xué)生成績基本想法:先讀取要編輯的學(xué)生姓名,然后與所有的學(xué)生姓名進(jìn)行比較,判斷是否在名單內(nèi),若不在,就輸出不在,否則 就再讀取該學(xué)生的5個成績到 marks 編碼實(shí)現(xiàn) void DeleteStudent(char* students,int* marks)int found, i,j;char* students1;int* marks1;students1 = *students;marks1 = *marks;char *name;printf(enter names of students to be deleted separated by commasn)

5、;name = ReadLine(); / 讀姓名if(students1 =NULL) return ;for(found = i = 0; students1i != NULL; i+)/ 判斷是否已經(jīng)存在該學(xué)生 if (strcmp(students1i,name) = 0) / 判斷函數(shù) 相同為0 found = 1; break; if (!found) /如果不同 printf(student %s not in the Class Listn,name); return; if(students1i+1!= NULL) /判斷下一個學(xué)生是否為空j=i+1;while(studen

6、ts1j!=NULL) /不為空時(shí),將學(xué)生信息向前移一位students1j-1=students1j;marks1j-1= marks1j;j+;students1j-1=NULL;marks1j-1= NULL;free(void*)students1j-1); / 釋放內(nèi)存free(void*)marks1j-1);elsestudents1i=NULL;marks1i = NULL;free(void*)students1i);free(void*)marks1i);*students = students1;*marks = marks1;free(void*)name); /釋放姓

7、名內(nèi)存void SortClass(char* students,int* marks)int i, j,k;char* students1,*stu1;int* marks1,*mar1;students1 = students;marks1 = marks;for(i = 0; students1i+1 != NULL; i+) / 最小冒泡排序法k=i;for(j=i+1;students1j !=NULL; j+)if(strcmp(students1j,students1k) 0) k=j;stu1 = students1k;students1k = students1i;stude

8、nts1i = stu1;mar1 = marks1k;marks1k = marks1i;marks1i = mar1;students = students1;marks = marks1; void ShowClass(char* students,int* marks)int i;fflush(stdout);if(students=NULL) /指針為空 則返回printf(Class is Empty!n);return;printf(Class List:n); printf(students:第一門第二門第三門第四門第五門 總分 n);for(i = 0; studentsi

9、!= NULL; i+)if(marksi0=-1&marksi1=-1&marksi2=-1&marksi3=-1&marksi4=-1)printf(%s: , , , , , n,studentsi);elseprintf(%s: %d, %d, %d, %d, %d %d n,studentsi,marksi0,marksi1,marksi2,marksi3,marksi4,(marksi0+marksi1+marksi2+marksi3+marksi4);return;void EditMarks(char* students,int* marks) /編輯學(xué)生成績int found

10、, i,score;char* students1;int* marks1;students1 = students;marks1 = marks;char *name;printf(Enter student name whose marks are to be edited:n);name = ReadLine();for(found = i = 0; students1i != NULL; i+) if (strcmp(students1i,name) = 0) / 相同為0 found = 1; printf(editing:%sn,name); break; if(!found) p

11、rintf(student %s not in the Class listn,name);while (found) /讀取輸入的五個成績 printf(to leave the 1st mark unchanged,press n); printf(otherwise type new mark and press n); scanf(%d,&score); while(score=0 & score =100) != 1) printf(incorrect mark entered,re-do:n); scanf(%d,&score); marksi0=score; printf(to

12、leave the 2nd mark unchanged,press n); printf(otherwise type new mark and press n); scanf(%d,&score); while(score=0 & score =100) !=1) printf(incorrect mark entered,re-do:n); scanf(%d,&score); marksi1=score; printf(to leave the 3rd mark unchanged,press n); printf(otherwise type new mark and press n)

13、; scanf(%d,&score); while(score=0 & score =100) !=1) printf(incorrect mark entered,re-do:n); scanf(%d,&score); marksi2=score; printf(to leave the 4th mark unchanged,press n); printf(otherwise type new mark and press n); scanf(%d,&score); while(score=0 & score =100) !=1) printf(incorrect mark entered

14、,re-do:n); scanf(%d,&score); marksi3=score; printf(to leave the 5th mark unchanged,press n); printf(otherwise type new mark and press n); scanf(%d%c,&score); /吃掉回車鍵 while(score=0 & score =100) !=1) printf(incorrect mark entered,re-do:n); scanf(%d%c,&score); marksi4=score; return; 四、程序調(diào)試(說明調(diào)試過程、問題及其解

15、決方法)1.在editmarks 這個函數(shù)中 我采用scanf這個函數(shù)來讀取成績,在讀取第五個成績的時(shí)候發(fā)現(xiàn)讀完后會在函數(shù)主菜單里出現(xiàn)一次的錯誤 這時(shí)我上網(wǎng)查了資料 發(fā)現(xiàn)應(yīng)該在第五個輸入成績的時(shí)候在%s后面再加一個%c 來吃掉一個回車鍵 這樣主菜單就不會出現(xiàn)菜單錯誤的情況 2.在調(diào)試的時(shí)候,剛運(yùn)行的時(shí)候在什么都沒有輸入的時(shí)候,馬上按2, ,發(fā)現(xiàn)程序就出現(xiàn)錯誤,我就在delete里面先加入一個判斷 指針是否為空 為空就返回 來避免錯誤五、總結(jié) 編程實(shí)習(xí)中 ,首先要看懂老師所給的部分程序,先了解老師給整個程序的基本方法,比如這個函數(shù)是用多級指針來完成這個程序 ,而不是用結(jié)構(gòu)體來做鏈表來實(shí)現(xiàn)的,只有這個先弄懂這些才能做到心中有數(shù)。在編程的過程中,要有系統(tǒng)的想法,知道整個框架是怎么構(gòu)成的。另外在編程基本完成后 要進(jìn)行全面的調(diào)試,針對各個情況都進(jìn)行嘗試,盡可能避免bug的錯誤六、思考題:為什么插入一個學(xué)生、掃除一個學(xué)生的函數(shù)(insertstudents、deletestud

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論