2022年c語言實驗報告三學生成績管理系統(tǒng)_第1頁
2022年c語言實驗報告三學生成績管理系統(tǒng)_第2頁
2022年c語言實驗報告三學生成績管理系統(tǒng)_第3頁
2022年c語言實驗報告三學生成績管理系統(tǒng)_第4頁
2022年c語言實驗報告三學生成績管理系統(tǒng)_第5頁
已閱讀5頁,還剩21頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、學習 - 好資料 1. 試驗內容 實現一個同學成果處理程序, 先輸入多名同學的學號和成果, 然 后進入菜單,可以選擇打印,添加,修改,刪除或查詢成果(學號查 詢和成果段查詢); 2. 試驗步驟 2.1 程序 1 2.1.1 程序功能 這是一個同學成果處理程序, 通過用戶輸入多名同學的學號和成 績,然后進入菜單, 可以選擇打印, 添加,修改,刪除或查詢成果 (學 號查詢和成果段查詢) ; 2.1.2 設計思路 將一個大程序分塊化處理, 各個部分先用一般方法實現, 在能運 行的條件下改用插入排序和折半查找實現;先實現輸入成果和菜單, 再一項一項實現菜單中的功能; 2.1.3 流程圖或其他描述(不要

2、求可以不寫) 2.1.4 程序代碼(要有注釋) /實現一個同學成果處理程序,可以選擇打印,添加,修改,刪除或 查詢成果(學號和成果段查詢) #include 更多精品文檔 第 1 頁,共 16 頁學習 - 好資料 #include #include #include #define N 80 typedef struct student long num; int score; STU; STU stuN; int n=0; int KEY=0; int k; void Input; void Output; void Add; void Direct; void Delete; void S

3、earch; 更多精品文檔 第 2 頁,共 16 頁學習 - 好資料 void Sch; void Save; void Read; void main int chos; systemcls; printfn; printf 同學成果治理系統(tǒng) nn; printf1. 錄入 n2.顯示 n3.添加 n4.修改 n; printf5. 刪除 n6.查找 n7.查詢 n8.退出 n; printfn 請選擇 : ; scanf%d, &chos; switchchos case 1: Input; break; case 2: 更多精品文檔 第 3 頁,共 16 頁學習 - 好資料 Output

4、; break; case 3: Add; break; case 4: KEY = 1; Search; break; case 5: Delete; break; case 6: Search; break; case 7: Sch; break; case 8: exit0; break; default: printf 錯誤 . 請按要求輸入 .; Sleep2000; main; void Input 更多精品文檔 第 4 頁,共 16 頁學習 - 好資料 int i=-1; systemcls; printf 當輸入學號為負時返回 .n; do i+; printfn; print

5、f 請輸入第 %2d 個同學的學號 : , i+1; scanf%ld, &stui.num; if stui.num 0 break; printf 請輸入第 %2d 個同學的成果 : , i+1; scanf%d, &stui.score; n+; whilei=0; if stui.num 0 Save; void Output systemcls; printfn; 更多精品文檔 第 5 頁,共 16 頁學習 - 好資料 Read; printfnn 任意鍵返回 .; getchar; getchar; main; void Add int i, j; systemcls; print

6、fn; printf 請輸入需添加同學的學號 : ; scanf%8ld, &stuN-1.num; printf 請輸入需添加同學的成果 : ; scanf%d, &stuN-1.score; for i=0; in; i+ 更多精品文檔 第 6 頁,共 16 頁學習 - 好資料 if stuN-1.num i; j- stuj.num = stuj-1.num; stuj.score = stuj-1.score; stui.num = stuN-1.num; stui.score = stuN-1.score; break; else stun.num = stuN-1.num; stu

7、n.score = stuN-1.score; break; n+; printf 修改后的 ; Save; 更多精品文檔 第 7 頁,共 16 頁學習 - 好資料 void Direct printf 請輸入修改后的成果 : ; scanf%d, &stuk.score; printf 修改后的成果為 :n; printft%8ldt%dn, stuk.num, stuk.score; printfnn; printf 修改后的 ; Save; void Delete int i, del; char key; systemcls; printf 請輸入要刪除信息的同學學號 : ; scan

8、f%ld, &del; getchar; printf 確認刪除 .Y/N; 更多精品文檔 第 8 頁,共 16 頁學習 - 好資料 scanf%c, &key; if key=y | key=Y for i=0; in; i+ if del = stui.num stui = stui+1; n -= 1; printf 修改后的 ; Save; void Search int i; char key = y; 更多精品文檔 第 9 頁,共 16 頁學習 - 好資料 long search; systemcls; if KEY=1 printfn 請輸入要修改成果同學的學號 : ; else

9、 printfn 請輸入要查詢成果同學的學號 : ; scanf%ld, &search; for i=0; in; i+ if search = stui.num printf 同學信息為 :n; printft%ldt%dn, stui.num, stui.score; k = i; if KEY = 1 Direct; KEY = 0; void Sch 更多精品文檔 第 10 頁,共 16 頁學習 - 好資料 int i, a ,b; systemcls; printf 請輸入您要查詢的成果段 A B: ; scanf%d %d, &a, &b; printf 符合條件的同學有 :n;

10、 for i=0; i=a & stui.score=b printft%ldt%dn, stui.num, stui.score; printf 任意鍵返回 .; getchar; getchar; main; void Save 更多精品文檔 第 11 頁,共 16 頁學習 - 好資料 FILE *fp; if fp=fopenscore.bin, wb = NULL printfFailed to save the data .n; exit0; fwrite stu, sizeofSTU, n, fp ; fclosefp; printf 同學成果已儲存在 score.bin 中.n;

11、 printfnn 任意鍵返回 .; getchar; getchar; main; void Read FILE *fp; int i, total; 更多精品文檔 第 12 頁,共 16 頁學習 - 好資料 printf 同學信息 :n; if fp=fopenscore.bin, rb = NULL printfFailed to read the data .n; exit0; for i=0; .feoffp ; i+ fread &stui, sizeofSTU, 1, fp ; fclosefp; total = i-1; for i=0; itotal; i+ printft%ldt%dn, stui.num, stui.score; printfnn 任意鍵返回 .; getchar; getchar; main; 更多精品文檔 第 13 頁,共 16 頁學習 - 好資料 2.1.5 運行結果 更多精品文檔 第 14 頁,共 16 頁學習 - 好資料 更多精品文檔 第 15 頁,共 16 頁學習 - 好資料 3試驗體會 調試中顯現的問題及解決過

溫馨提示

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

評論

0/150

提交評論