




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、基于C語言的學(xué)生作業(yè)完成情況管理程序的設(shè)計與實現(xiàn)設(shè)計者:軟件1204 劉嵩 12301103學(xué)生作業(yè)完成情況管理程序1. 需求分析1.1系統(tǒng)介紹這是一個簡易的學(xué)生作業(yè)完成情況管理系統(tǒng),主要面向在校教師統(tǒng)計、查詢、分析學(xué)生的作業(yè)完成情況,對教學(xué)做出正確指導(dǎo)。該系統(tǒng)操作簡單,功能全面,通過本系統(tǒng)教師能夠輕松的實現(xiàn)對學(xué)生成績的統(tǒng)計、查詢、分析、修改、增刪。大大的提高了教師的辦公效率。1.2基礎(chǔ)功能1.2.1學(xué)生成績錄入通過此功能用戶能夠?qū)崿F(xiàn)對學(xué)生各科成績的統(tǒng)計。1.2.2個人成績查詢通過輸入學(xué)生學(xué)號或姓名,用戶能夠輕松地找到所需學(xué)生的作業(yè)完成信息。1.2.3班級成績查詢通過輸入班級名稱,用戶能夠?qū)崿F(xiàn)
2、對某班全體學(xué)生成績的查詢。1.2.4信息修改用戶通過此功能修改和刪除班級或?qū)W生信息。1.2.5其他功能A計算個人平均成績B計算班級平均成績C計算班級及格率D班級排名E年級排名1.3開發(fā)環(huán)境與開發(fā)語言1.3.1開發(fā)環(huán)境基于Visual Stdio 2012de C語言Windows集成環(huán)境1.3.2開發(fā)語言C語言2.系統(tǒng)架構(gòu)不fvhfnbjfknbfn2.1系統(tǒng)架構(gòu)圖退出系統(tǒng)刪除信息統(tǒng)計模塊 修改信息查詢模塊輸入學(xué)生成 績主菜單學(xué)生作業(yè)完成情況管理系統(tǒng)登陸密碼鍵盤輸入 文件導(dǎo)入退出刪除某生全部成績刪除某生部分成績退出系統(tǒng) 按學(xué)號查詢某生平均成績查詢某班某次作業(yè)成績 查詢某班學(xué)生作業(yè)的平均成績 某
3、班及格率 修改密碼退出系統(tǒng) 學(xué)號查詢 班級查詢?nèi)啃畔⑼顺鱿到y(tǒng) 2.2文件和函數(shù)信息2.2.1頭文件StudentWork.h設(shè)計2.2.1.1輸入提示Help.cint printf_help();int Printf_help2();int Printf_help3();int Printf_help4();int Printf_help5();2.2.1.2清空緩沖區(qū)函數(shù)Clear.cvoid clear();2.2.1.3文件判斷judge.cFILE *judge1();FILE *judge2(char);2.2.1.4將文件轉(zhuǎn)換華為鏈表Menufile.cstruct stude
4、nt *ftoli(FILE *,struct student *); void menu(struct student *,FILE *);CreatNode.cstruct student *sortandinsert(struct student*,struct student*,FILE *);struct student *CreateNode(char *,FILE *);2.2.1.5插入模塊InsertDoc.cstruct student *insert1(struct student *,FILE *);struct student *insertf(struct stud
5、ent *,FILE *);2.2.1.6統(tǒng)計模塊Conclu.cvoid average(struct student *);/*某學(xué)生平均成績*/void searchClass(struct student *);/*按班級查詢成績*/void search(struct student *);void jigelv(struct student *);2.2.1.7讀取ReadFile.c與存入PutFile.cvoid readFile1(struct student*,int);/display the link according to student IDvoid readFi
6、le2(struct student*,int);/display the link according to classvoid readFile3(struct student*);/display the linkvoid saveFile(struct student *,FILE *);2.2.1.8密碼模塊PassWord.cvoid secret(FILE *);void secret2();void changesecret(FILE *);2.2.1.9修改模塊Alter.cstruct student *modify(struct student*,FILE *,int);
7、2.2.1.10刪除模塊Delate.cstruct student *delete1(struct student*);struct student *delete2(struct student*,FILE *);Main()secret2()system("color 0M");judge1()sortandinsert()CreateNode()ftoli(outfile,head)average(head)Printf_help5() changesecret(infile)jigelv(head)searchClass(head) search(head)del
8、ete2(head,infile)saveFile(head,infile)delete1(head)Printf_help4()Printf_help3()readFile2(head,a)readFile1(head,a)readFile3(head)modify(head,infile,q) saveFile(head,infile) readFile1(head,q)Printf_help2()insert1()insertf(head,infile)3.1.1由main()起始的調(diào)用menu(head,outfile)3.2.1各函數(shù)功能3.2.1.1輸入成績模塊函數(shù)名參數(shù)列表返回值
9、功能解釋Printf_help2()無無輸入提示insert1()struct student *head,FILE *infilehead叢鍵盤輸入成績及Insertf()Structstudent *head,FILE *infilehead從文件導(dǎo)入成績3.2.1.2刪除模塊函數(shù)名參數(shù)列表返回值功能解釋Printf_help4()無無輸入提示delete1()struct student *headhead刪除所有成績delete2()struct student *head,FILE *outfilehead刪除部分成績3.2.1.3查詢模塊函數(shù)名參數(shù)列表返回值功能解釋Printf_h
10、elp3()無無輸入提示readFile1(head,a)struct student *head,a無學(xué)號查成績readFile2()struct student *head,a無班級查成績readFile3()struct student *head無所有成績及3.2.1.4修改模塊函數(shù)名參數(shù)列表返回值功能解釋modify()head,infile,qhead輸入提示readFile1()struct student *head,q無導(dǎo)入成績saveFile()struct student *head,FILE *infile無保存修改3.2.1.5保密模塊函數(shù)名參數(shù)列表返回值功能解釋se
11、cret()FILE *outfile無修改刪除密碼changesecret()FILE *outfile無修改密碼secret2()無無登錄密碼3.2.1.6統(tǒng)計模塊函數(shù)名參數(shù)列表返回值功能解釋Printf_help5()無無輸入提示average()struct student *head無某學(xué)生平均成績jigelv()struct student *head,無某班及格率searchClass()struct student *head無查詢某班某次作業(yè)成績 search()struct student *head無查詢某班學(xué)生作業(yè)的平均成績4. 測試過程及結(jié)果4.1測試用例 測試成功4
12、.2運行結(jié)果 運行成功5.1使用說明手冊程序中有傻瓜式提示6.1有待改進的方面在編寫的過程中由于技術(shù)的限制會遇到各種不盡人意的地方,具體如下:1. 由于技術(shù)有限,對于異常情況的處理未能進行;2. 功能有缺陷,執(zhí)行一個命令后不能返回菜單繼續(xù)操作;3. 程序結(jié)構(gòu)不合理,稍顯混亂。7.1自我體會1. 軟件作為一個工程,事先必須有一個詳盡的策劃,才能保證工程有條不紊的進行。2. 各種C語言的技術(shù)應(yīng)當(dāng)爛熟于心才能更好更快的找到最優(yōu)的解決方案,而避免了不停地翻書,耽擱時間。8.1參考文獻C語言程序設(shè)計、表準(zhǔn)C語言基礎(chǔ)教程。10附源代碼清單程序源代碼要求:函數(shù)名、變量名要規(guī)范命名;源代碼的書寫采用遞進格式;
13、程序行和程序段須有注釋/Student Main.c/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <windows.h>#include "StudentWork.h"/*創(chuàng)建一個學(xué)生信息結(jié)構(gòu)*/ struct studentint classnum; /班級char name20; /姓名int stuID; /學(xué)號float score11; /分數(shù)struct student *nextaddr; ;int main()FILE *ou
14、tfile;struct student *head;secret2();clear();system("color 0M");/*屏幕*/ printf(" n*");printf(" n*=*",1,1); printf(" n* 歡迎使用學(xué)生作業(yè)完成情況管理程序 *",1,1); printf(" n* 北京交通大學(xué) 軟件學(xué)院 *",1,1);printf(" n* 1204 劉嵩 *",1,1);printf(" n*=*",1,1); print
15、f("n*n");printf("nt請按【Enter】鍵進入該系統(tǒng)");getchar();clear();/清屏outfile=judge1();/判斷文件能否打開head=NULL;head=ftoli(outfile,head);/調(diào)用函數(shù)建立鏈表menu(head,outfile);return 0;/Menufile.c/#include <stdio.h>#include <conio.h>#include <stdlib.h>#include "StudentWork.h"struc
16、t studentint classnum;char name20;int stuID;float score11;struct student *nextaddr;/ 將文件中的信息讀到函數(shù)struct student *ftoli(FILE *outfile,struct student *head)char a;char string11000;struct student *p;/judge whether the file is validif(a=fgetc(outfile)=EOF)exit(1);rewind(outfile);while(fgets(string1,1000,
17、outfile)!=NULL) p=CreateNode(string1,outfile);head=sortandinsert(p,head,outfile);/a founction that can sort and insert code from file.return (head);void menu(struct student *head,FILE *infile)int c1,c2,c3,c4,c5;int a,q,b,j;struct student *p;do printf("nn"); for(b=0;b<80;+b) printf("
18、;%c%c%c",1,3,1);_sleep(0.1);system("cls");for(j=0;j<b;+j)putchar(' ');printf("n");c1= Printf_help();clear;switch(c1)case 1:/input datac2=Printf_help2();clear();switch(c2)case 1:head=insert1(head,infile);/insert from the keyboardbreak;case 2:head=insertf(head,infil
19、e);/insert from filebreak;case 3:fclose(infile);exit(1);break;default:printf("您的輸入不符合要求,請重試。");fclose(infile);exit(1);clear();/clear the screenbreak;/search datacase 2:c3=Printf_help3();switch(c3)case 1: lab_2:printf("n請輸入該學(xué)生的學(xué)號:");scanf("%d",&a);getchar();readFile1
20、(head,a);/search by student's ID,and return the adress of the studentprintf("n按【y】繼續(xù)。");if(getchar()='y')goto lab_2;break;case 2:lab_3:printf("n請輸入該班級:");scanf("%d",&a);getchar();readFile2(head,a);/search by class.no return ,it call the fonuction that th
21、e founction input1printf("n按【y】繼續(xù)。");if(getchar()='y')goto lab_3;break;case 3:lab_4:readFile3(head);printf("n按【y】繼續(xù)。");if(getchar()='y')goto lab_4;break;case 4:fclose(infile);exit(1);break;default:printf("您的輸入不符合要求,請重試。");fclose(infile);exit(1);clear();/
22、clear the screenbreak;/modify datacase 3:printf("n請輸入你想修改的學(xué)生的學(xué)號:"); scanf("%d",&q); getchar();head=modify(head,infile,q);/it call the founction output1printf("n現(xiàn)在該生信息為:n"); readFile1(head,q); saveFile(head,infile);clear();/clear the screenbreak;/delete datacase 4: c
23、4=Printf_help4();switch(c4)case 1:/delete all the data of a studenthead=delete1(head);saveFile(head,infile);break;case 2:/delete some data of a stydenthead=delete2(head,infile);break;case 3:fclose(infile);exit(1);break;default:printf("您的輸入不符合要求,請重試。");fclose(infile);exit(1);clear();/clear
24、the screenbreak;/拓展模塊case 5: c5=Printf_help5(); switch(c5) case 1: average(head); break; case 2: searchClass(head); break; case 3: search(head); break; case 4: jigelv(head); break; case 5: changesecret(infile); break; case 6: fclose(infile); exit(1); break; default: printf("您的輸入不符合要求,請重試。"
25、); fclose(infile); exit(1); clear(); break;case 6:fclose(infile);exit(1);break; while(1);return ;/ReadFile.c/#include <stdio.h>struct studentint classnum;char name20;int stuID;float score11;struct student *nextaddr;/the founction can display all the date.void readFile1(struct student* head,int
26、 stuid)/display according to student ID.struct student *content;int i=0,j=0;content=head;while(content!=NULL)if(content->stuID=stuid)j=1;printf("n班級 姓名 學(xué)號 作業(yè)成績n");printf("n%d %s %d ",content->classnum,content->name,content->stuID);while(content->scorei!=-1) printf(
27、"%4.1f ",content->scorei); i+;content=content->nextaddr;printf("n");if(j=0)printf("n文件中未找到該生信息。");return ;void readFile2(struct student*head,int classn)/display according to class.struct student *content;int i=0;content=head;printf("n班級 姓名 學(xué)號 作業(yè)成績n");whi
28、le(content!=NULL)i=0;if(content->classnum=classn)printf("n%d %s %d ",content->classnum,content->name,content->stuID);while(content->scorei!=-1) printf(" %4.1f ",content->scorei); i+;printf("n");content=content->nextaddr;return ;void readFile3(struct
29、 student *head)/display all.struct student *content;int i=0;content=head;printf("n班級 姓名 學(xué)號 作業(yè)成績n");while(content!=NULL)i=0;printf("n%d %s %d ",content->classnum,content->name,content->stuID);while(content->scorei!=-1) printf("%4.1f ",content->scorei); i+;
30、printf("n");content=content->nextaddr;return ;/PutFile.c/#include <stdio.h>#include <string.h>#include <stdlib.h>#include <ctype.h>#include "StudentWork.h"struct studentint classnum;char name20;int stuID;float score11;struct student *nextaddr;void saveF
31、ile(struct student *head,FILE *infile)char c;struct student*content;int i;doprintf("您想保存已做的更改嗎?(y or n):");c=getchar();c=tolower(c);getchar();if (c='y')secret(infile);rewind(infile);content=head;while(content!=NULL)fprintf(infile,"%d %s %d ",content->classnum,content-&
32、gt;name,content->stuID);i=0;while(content->scorei!=-1)fprintf(infile,"%4.1f ",content->scorei);i+;fputc('n',infile);content=content->nextaddr;printf("所做更改已保存。");break;if (c='n')printf("所做更改未保存。");break;elseprintf("所輸入不符合要求,請重新輸入。");
33、while(1);printf("n請按ENTER鍵以繼續(xù)。");getchar();return ;/PassWord.c/#include <stdio.h>#include <string.h>#include <stdlib.h>#include <windows.h>void secret(FILE *outfile)FILE *infile;char a50,b50;int i=1;infile=fopen("password.txt","r");fgets(a,60,inf
34、ile);doprintf("nt對文件進行修改輸入密碼:");gets(b);if(strcmp(a,b)=0)break;elseprintf("nt密碼錯誤,請重新輸入!");if(i>=3)printf("nt您已輸入三次錯誤密碼,系統(tǒng)將自動退出!");fclose(outfile);fclose(infile);exit(1);i+;while(1);fclose(infile);return ;void changesecret(FILE *outfile) FILE *infile;char a50,b50,c50
35、;int i=1;lab_1:system("color 0H");infile=fopen("password.txt","r+");fgets(a,60,infile);doprintf("nt輸入舊密碼:");gets(b);if(strcmp(a,b)=0)printf("nt輸入新密碼:");gets(c);rewind(infile);fputs(c,infile);printf("nt密碼已修改");fclose(infile);break;elseprintf
36、("nt密碼錯誤,請重新輸入!");if(i>=3)printf("nt您已輸入三次錯誤密碼,系統(tǒng)將自動退出!");fclose(outfile);fclose(infile);exit(1);i+;while(1);printf("nt請按【y】鍵繼續(xù)。");if(getchar()='y')goto lab_1;return ;/登錄密碼void secret2()FILE *infile2,*outfile;char a250,b250;int i=1;infile2=fopen("passwor
37、d2.txt","r");fgets(a2,60,infile2);doprintf("nt登陸輸入密碼:");gets(b2);if(strcmp(a2,b2)=0)break;elseprintf("nt密碼錯誤,請重新輸入!");if(i>=3)printf("nt您已輸入三次錯誤密碼,系統(tǒng)將自動退出!");fclose(outfile);fclose(infile2);exit(1);i+;while(1);fclose(infile2);return ;/Judge.c/#include
38、<stdio.h>#include <stdlib.h>#include <string.h>#include <stdio.h>#include <string.h>#include <stdlib.h>#include "StudentWork.h"struct studentint classnum;char name20;int stuID;float score11;struct student *nextaddr;FILE * judge1()FILE *infile;char d;infi
39、le=fopen("Student'Score.dat","r");if (infile=NULL)printf("n打開文件Student'Score.dat失敗,請檢查文件是否存在并重試。");exit(1);infile=fopen("Student'Score.txt","a+");if(infile=NULL)printf("nt打開文件失敗,請重試。n");exit(1);printf("nt打開文件成功n");d=fg
40、etc(infile);if(d=EOF)printf("nt文件為空,請先向文件中錄入信息n");return (infile);FILE * judge2(char f)FILE *infile;char d;infile=fopen(f,"r");if (infile=NULL)printf("n打開文件Student'Score.dat失敗,請檢查文件是否存在并重試。");exit(1);infile=fopen("Student'Score.txt","a+");if(
41、infile=NULL)printf("nt打開文件失敗,請重試。n");exit(1);printf("nt打開文件成功n");d=fgetc(infile);if(d=EOF)printf("nt文件為空,請先向文件中錄入信息n");return infile;/nsertDoc.c/#include <stdio.h>#include <string.h>#include <stdlib.h>#include "StudentWork.h"struct studentint
42、 classnum;char name20;int stuID;float score11;struct student *nextaddr;/*錄入成績*/struct student *insert1(struct student *head,FILE *infile)struct student * p,*content;int i=0,c,a,b;float m;int z=0; printf(" 手動錄入 n"); printf(" 【1】錄入一位新學(xué)生。 n"); printf("+n"); printf(" 【
43、2】錄入某班某次作業(yè)成績。 n"); printf("+n");printf(" 【3】錄入某學(xué)生某次作業(yè)成績。 n");printf("+n");printf(" 【4】錄入所有學(xué)生某次作業(yè)的成績 n");printf("+n");printf(" 【5】退出系統(tǒng)。 n"); printf("n"); printf("n%c請輸入序號進入相應(yīng)的功能:",3); scanf("%d",&c);get
44、char();switch(c)case 1:/enter a new studentp=(struct student *)malloc(sizeof(struct student);if(p=NULL)printf("n開辟地址空間失敗.n");fclose(infile);exit(0);printf("n%c請鍵入該新生班級:",1);scanf("%d",&p->classnum);getchar();printf("n%c請鍵入該生姓名:",1);gets(p->name);printf("n%c請鍵入該生學(xué)號:",1);scanf("%d",&p->stuID);getchar();printf("n%c請鍵入該生若干次作業(yè)的成績.【負數(shù)】停止鍵入:n",1);while (1)scanf("%f",&m);getchar();if(m<0)break;p->scorei=m;i+;p->scorei=-1;head=sortandinsert(p,head,infile);/add the new student to
溫馨提示
- 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年河北工業(yè)職業(yè)技術(shù)大學(xué)單招職業(yè)適應(yīng)性測試題庫完整版
- 2025年河源職業(yè)技術(shù)學(xué)院單招職業(yè)適應(yīng)性測試題庫參考答案
- 2025年黑龍江省鶴崗市單招職業(yè)適應(yīng)性測試題庫及參考答案
- 2025年廣東省外語藝術(shù)職業(yè)學(xué)院單招職業(yè)技能測試題庫帶答案
- 2025年廣州體育職業(yè)技術(shù)學(xué)院單招職業(yè)技能測試題庫完美版
- 2025年合肥財經(jīng)職業(yè)學(xué)院單招職業(yè)技能測試題庫1套
- SMIC ERP BPR項目軟件版本升系正式變更 接口單點測試 6-1-332-某大型企業(yè)SAP ERP方案17
- 中級家庭照顧員練習(xí)測試卷
- 主護專復(fù)習(xí)測試題
- 2025年湖南省邵陽市單招職業(yè)適應(yīng)性測試題庫1套
- P氣瓶充裝模擬考試題及答案
- 社區(qū)獲得性肺炎(1)護理病歷臨床病案
- 新人教版高中數(shù)學(xué)必修第一冊-3.3 冪函數(shù)【課件】
- 生物基有機硅材料的研究進展及前景展望
- 國有企業(yè)保密管理制度
- 一年級上冊數(shù)學(xué)試題-期中試卷五 蘇教版(含答案)
- Unit2大單元整體教學(xué)設(shè)計-小學(xué)英語四年級上冊(Joinin外研劍橋英語)
- 鄉(xiāng)村振興背景下農(nóng)業(yè)碩士產(chǎn)教融合培養(yǎng)模式的創(chuàng)新
- 人美版(2024)七年級上冊美術(shù)第二單元 色彩魅力第1課《自然的色彩》教學(xué)設(shè)計
- 2024年高級纖維檢驗員職業(yè)鑒定理論考試題庫(含答案)
- 心肺復(fù)蘇科普課件
評論
0/150
提交評論