學生成績管理系統(tǒng)-C語言課程設計-源代碼_第1頁
學生成績管理系統(tǒng)-C語言課程設計-源代碼_第2頁
學生成績管理系統(tǒng)-C語言課程設計-源代碼_第3頁
學生成績管理系統(tǒng)-C語言課程設計-源代碼_第4頁
學生成績管理系統(tǒng)-C語言課程設計-源代碼_第5頁
已閱讀5頁,還剩5頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、#include#include#include#include #include struct chengji /* 成績構(gòu)造體*/ int point;char subject20; ; struct student /* 學生構(gòu)造體*/ int w; char name20; int number; struct chengji cheng30; float sum; float average; stu40; void pjun(); /*按平均分排序*/ void pfen(); /*按總分排序*/ void addnew(); /*錄入學生成績*/ void pall(); /*顯

2、示所有成績*/ void check(); /*查詢菜單*/ void pnum(); /*按學號排序*/ void pjing(); /*準確查找*/*/ /*主菜單*/ main() char choose; while(1) printf(ntt*); printf(ntt* 歡送使用成績管理系統(tǒng) *); printf(ntt* *); printf(ntt* 請選擇 *); printf(ntt* 1. 錄入學生成績 *); printf(ntt* 2. 查詢學生成績 *); printf(ntt* 3. 清屏 *); printf(ntt* 0. 退出程序 *); printf(nt

3、t* *); printf(ntt*); printf(nn); printf(請選擇:); scanf(%c,&choose);getchar(); switch(choose) case 1: addnew(); break; case 2: check(); break; case 3: system(cls); break; case 0: exit(0); break;default: printf(輸入錯誤,請從新輸入!nn); /*/ /*錄入學生成績*/ void addnew() int n,m,i,p; float sum; float average; FILE *fil

4、e; sum=0.00000; average=0.00000; if(c:student.dat,rb)=NULL) file = fopen(c:student.dat, wb+); /* 創(chuàng)立一個文件*/ printf(請輸入需要錄入的學生人數(shù): ); scanf(%d,&n); for(i=0;in;i+) printf(輸入第%d個同學信息:n,i+1); printf(姓名:); scanf(%s,&); printf(學號:); scanf(%d,&stui.number); printf(輸入科目個數(shù): ); scanf(%d,&m); stui.w=m; p

5、rintf(按科目回車成績回車的順序輸入: n); /* 錄入成績*/ for(p=0;pm;p+) scanf(%s,&stui.chengp.subject); scanf(%d,&stui.chengp.point); stui.sum=stui.sum+stui.chengp.point; stui.average=stui.sum/m; /* printf(總分%f , 平均分%fn ,stui.sum,stui.average);*/ fwrite(&stui,sizeof(stu),1,file); /* 把stu寫入文件*/ fclose(file); /* 關閉文件*/ ff

6、lush(stdin); system(cls); /*/ /*查詢菜單*/void check() while(1) char choose; printf(ntt*); printf(ntt* 查詢菜單 *); printf(ntt* *); printf(ntt* 請選擇 *); printf(ntt* 1. 按學號排列 *); printf(ntt* 2. 按總分排列 *); printf(ntt* 3. 按平均分排列 *); printf(ntt* 4. 準確查詢 *); printf(ntt* 5. 顯示所有學生成績 *); printf(ntt* 6. 清屏 *); printf

7、(ntt* 0. 返回 *); printf(ntt*); printf(nn); printf(請選擇:); scanf(%c,&choose);getchar(); switch(choose) case 1: pnum(); break; case 2: pfen(); break; case 3: pjun(); break;case 4: pjing(); break;case 5: pall(); break;case 6: system(cls); break;case 0: main(); break; /*/ /*顯示所有成績*/ void pall() int i=0,m;

8、 FILE *file; if(c:student.dat,rb)=NULL) printf(Open error!n); getch(); exit(0); fread(&stui,sizeof(stu),1,file); while(feof() /* 循環(huán)整個文件*/ printf(姓名-學號-總分-平均分n); printf(%s %5d %10.1f %8.1fn,,stui.number,stui.sum,stui.average); printf( 科目-成績n); for(m=0;m0;j-) for(i=0;istui+1.number) /*比照學號,對換

9、stu*/ bm=stui; /*交換位置*/ stui=stui+1; stui+1=bm; for(i=0;in;i+) /* 交換后從新排序*/ printf(姓名-學號-總分-平均分n); printf(%s %5d %10.1f %8.1fn,,stui.number,stui.sum,stui.average); printf( 科目-成績n); for(m=0;m0;j-) for(i=0;ij;i+) if(stui.sumstui+1.sum) bm=stui; stui=stui+1; stui+1=bm; for(i=0;in;i+) printf(姓名

10、-學號-總分-平均分n); /*顯示到屏幕*/ printf(%s %5d %10.1f %8.1fn,,stui.number,stui.sum,stui.average); printf( 科目-成績n); for(m=0;m0;j-) for(i=0;ij;i+) if(stui.averagestui+1.average) bm=stui; stui=stui+1; stui+1=bm; for(i=0;in;i+) printf(姓名-學號-總分-平均分n); printf(%s %5d %10.1f %8.1fn,,stui.number,stu

11、i.sum,stui.average); printf( 科目-成績n); for(m=0;mstui.w;m+) printf(%40s %d n,stui.chengm.subject,stui.chengm.point); fclose(file); fflush(stdin); /*/ /*準確查找*/ void pjing() int n; int i=0; int m; FILE *file; if(c:student.dat,rb)=NULL) printf(Open error); getch(); exit(0); printf(請輸入要查詢的學生的學號:); scanf(%d,&n);getchar(); fread(&stui,sizeof(stu),1,file); while(feof() if(n=stui.number) /*輸出對應的學號的學生成績*/ printf(姓名-學號-總分-平均分n); printf(%s %5d %10.1f %8.1fn,,stui.number,stui.sum,stui.

溫馨提示

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

評論

0/150

提交評論