學生選課管理系統(全源代碼,Linux環境)_第1頁
學生選課管理系統(全源代碼,Linux環境)_第2頁
學生選課管理系統(全源代碼,Linux環境)_第3頁
學生選課管理系統(全源代碼,Linux環境)_第4頁
已閱讀5頁,還剩47頁未讀 繼續免費閱讀

下載本文檔

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

文檔簡介

1、/*/*/list.h 文件#ifndef _LIST_H#define _LIST_H#define _INLINE_ static inlinestruct list_head struct list_head *next, *prev;#define LIST_HEAD_INIT(name) &(name), &(name)#define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name)#define INIT_LIST_HEAD(ptr) do (ptr)->next = (ptr); (pt

2、r)->prev = (ptr); while (0)_INLINE_ void _list_add(struct list_head *add,struct list_head *prev,struct list_head *next)next->prev = add;add->next = next;add->prev = prev;prev->next = add;_INLINE_ void list_add(struct list_head *add, struct list_head *head) _list_add(add, head, head-&g

3、t;next);_INLINE_ void list_add_tail(struct list_head *add, struct list_head *head)_list_add(add, head->prev, head);_INLINE_ void _list_del(struct list_head *prev, struct list_head *next)next->prev = prev;prev->next = next;_INLINE_ void list_del(struct list_head *entry)_list_del(entry->pr

4、ev, entry->next);_INLINE_ void list_del_init(struct list_head *entry)_list_del(entry->prev, entry->next);INIT_LIST_HEAD(entry);_INLINE_ int list_empty(struct list_head *head)return head->next = head;_INLINE_ void list_splice(struct list_head *list, struct list_head *head)struct list_head

5、 *first = list->next;if (first != list) struct list_head *last = list->prev;struct list_head *at = head->next;first->prev = head;head->next = first;last->next = at;at->prev = last;#define list_entry(ptr, type, member) (type *)(char *)(ptr) - (unsigned long)(&(type *)0)->m

6、ember)#define list_for_each(pos, head) for (pos = (head)->next; pos != (head); pos = pos->next)#define list_for_each_safe(pos, pnext, head) for (pos = (head)->next, pnext = pos->next; pos != (head); pos = pnext, pnext = pos->next)#undef _INLINE_#endif/* *8 /* /* * 頭文件 head.h#ifndef _H

7、EAD_H_ #define _HEAD_H_ #include<string.h> #include"list.h" #include<stdio.h> #include<stdlib.h> #include<time.h> #define Y #define N'y''n'#define A_FLAG 'a'#define S_FLAG 's'#define T_FLAG 't'extern struct list_head stu;/exte

8、rn struct list_head tec;/科目信息 typedef struct subject_infofloat SUB_notes3;/科目成績intSUB_csscore;/科目學分charSUB_csname32;/科目名稱structlist_head list;SUB;/學生信息typedef struct STU_infofloat STU_totalscore;intSTU_id;intSTU_age;intSTU_grade;intSTU_place;char STU_name32;char STU_psword32;SUBstructlist_head list;

9、subject3;/總分/學號/年齡/年級/名次/姓名/密碼STU;/教師信息 :typedef struct TCH_infointTCH_id;char TCH_name32;char TCH_psword32;SUB subject1;structlist_head list;TEC;/管理員信息typedef struct ADM_infochar ADM_usename8;char ADM_psword6;ADM;ADM use1;void gettime();void main_menu();void stu_login();void openf (char *filename);

10、void tec_login();void adm_login();void adm_nextmenu();void a_updt_stuinfo();void a_updt_tecinfo();void a_updt_myinfo();息void a_add_stuinfo();void a_add_tecinfo();void a_mdify_stuinfo();void a_del_info(char flag);void a_mdify_tecinfo();void a_seek_stuinfo();void a_seek_tecinfo();void show (char flag)

11、;void save (char flag,char system);void check(char flag);void commom();void a_show(char flag);/工號/姓名/密碼/獲取當前時間/主菜單/學生登錄/判斷文件是否存在/老師登錄/管理員登錄/管理員 2 級菜單/操作學生信息/操作老師信息/ 操作管理 員自身 信/添加學生信息/添加老師信息/修改學生信息/刪除信息/修改老師信息/查找學生信息/查找老師信息/顯示信息/保存信息/驗證密碼/公用函數集合/顯示信息void a_seek_info(char flag);void a_mdify_info(char

12、flag);void stu_nextmenu(int tmpid);void tec_nextmenu(int tmpid);void s_show_myinfo(int tmpid);void t_show_myinfo(int tmpid);void s_updt_myinfo(int tmpid);/查找信息/修改學生或老師信息/學生菜單/老師菜單/學生顯示自己信息/教師顯示自己信息/學生更新自己信息void s_select_subject(int tmpid);void t_updt_stuinfo(int tmpid);void t_updt_myinfo(int tmpid);

13、void readf();/學生選課/教授更新自己信息/教授顯示自己信息/從文件中讀取信息void stu_sort();float ave (float core3);float (*f)(float core3);int inputpsword(char *pass);void a_chpsword();#endif/*/*/入口 main 函數#include<stdio.h>#include<stdlib.h>#include<string.h>#include<time.h>#include"head.h"LIST_

14、HEAD(stu);LIST_HEAD(tec);int main()readf();system("clear");printf("ttt* *tt*n* *tt* *tt*Copyright (c) 2010, 易嵌教育 All rights reserved.nn* *tt* n* *tt* *tt*軟件名稱:學生選課管理系統摘 要 :nn* *tt* n* *tt* *tt*當前版本: 1.1n作者:關仁杰n* *tt*完成日期: 2010 年 8 月 2 日 n* *tt*n");/void delay(unsinged int)sleep(2

15、);main_menu();return 0;void main_menu()int ch;char hc;system("clear");gettime();printf("ttt=學生信息管理系統=nn");printf("tt#n");printf("tt= 歡迎使用本系統a =n");printf("tt#nn");printf("tt+n");printf("tt=1.學生=n");printf("tt=2.教師=n");pr

16、intf("tt=3.管理員=n");printf("tt=4.退出=n");printf("tt+n");printf(" 請輸入您選擇的序號:n");scanf("%d",&ch);switch(ch)case 1:printf(" 您的身份是學生!n 請登錄: n");gettime();openf("student.txt");check(S_FLAG);break;case 2:printf(" 您的身份是教師!n 請登錄: n

17、");gettime();openf("teacher.txt");check(T_FLAG);break;case 3:printf(" 您的身份是管理員!n 請登錄n");gettime();adm_login();break;case 4:printf("n");printf("aaa 您已經保存相應的數據了嗎?(y or n)n");getchar();scanf("%c",&hc);if(hc='y')|(hc='Y')printf(&

18、quot; 謝謝您使用本系統,如有需要請聯系:printf(" 請按 Enter 鍵退出! n");getchar();getchar();exit(0);QQ: n");else if(hc='n')|(hc='N')printf(" 您還沒有保存,系統將為您自動保存!n");save(S_FLAG,Y);break;default:printf(" 您的輸入有誤,請返回上級菜單!n");getchar();getchar();main_menu();/試讀文件,驗證是否建立void ope

19、nf(char *filename)FILE *fp;if(fp=fopen(filename,"r")=NULL)filename=NULL;printf(" 對不起!還沒有建立相應的信息!n 請于管理員聯系!n");getchar();getchar();main_menu();fclose(fp);/管理員登錄void adm_login()char psword6;FILE *fp;int i=0;if(fp=fopen("psword.txt","r")=NULL)printf(" 對不起沒有相

20、應的信息,請您建立!n");printf(" 請輸入您的用戶名(不得多于8 個字符): n");scanf("%s",use0.ADM_usename);printf(" 請輸入您的密碼:n");while(pswordi=getchar()!='n'|(pswordi=getchar()!=EOF|i<6)putchar('*');i+;strcmp(use0.ADM_psword,psword);save(A_FLAG ,N);/save the infomain_menu();el

21、secheck(A_FLAG);fclose(fp);/*/*/*/管理員相關函數#ifndef _ADM_nextmenu_c#define _ADM_nextmenu_c#include<stdio.h>#include<string.h>#include<stdlib.h>#include"head.h"struct list_head *postion;void adm_nextmenu()int ch;system("clear");gettime();printf("tttt*n");p

22、rintf("nntt#n");printf("tt=1.更改學生信息=n");printf("tt=2.更改老師信息=n");printf("tt=3.更改自己信息=n");printf("tt=4.返回主菜單=n");printf("tt#nn");printf(" 請輸入您選擇的代號:");scanf("%d",&ch);switch(ch)case 1:a_updt_stuinfo();break;case 2: a_u

23、pdt_tecinfo();break;case 3: a_updt_myinfo();break;case 4: printf(" 按 Enter 鍵返回主菜單!n");getchar();getchar();main_menu();break;default:printf("error!n");getchar();getchar();main_menu();/update infovoid a_updt_stuinfo()int ch;system("clear");gettime();printf("tttt*n&qu

24、ot;);printf("nntt#n");printf("tt=1.添加學生信息=n");printf("tt=2.刪除學生信息=n");printf("tt=3.查找學生信息=n");printf("tt=4.修改學生信息=n");printf("tt=5.返回上一級菜單=n");printf("tt#nn");printf(" 請輸入您選擇的代號:");scanf("%d",&ch);switch(ch

25、)case 1: a_add_stuinfo();break;case 2: a_del_info(S_FLAG);break;case 3: a_seek_stuinfo();break;case 4: a_mdify_info(S_FLAG);break;case 5: save(S_FLAG,N);printf(" 按 Enter 返回上一級菜單!n");getchar();getchar();adm_nextmenu();break;default:printf("error!n");getchar();getchar();main_menu()

26、;/update infovoid a_updt_tecinfo()int ch;system("clear");gettime();printf("tttt*n");printf("nntt#n");printf("tt=1.添加老師信息=n");printf("tt=2.刪除老師信息=n");printf("tt=3.查找老師信息=n");printf("tt=4.修改老師信息=n");printf("tt=5.返回上一級菜單=n"

27、);printf("tt#nn");printf(" 請輸入您選擇的代號:");scanf("%d",&ch);switch(ch)case 1: a_add_tecinfo();break;case 2: a_del_info(T_FLAG);break;case 3: a_seek_tecinfo();break;case 4: a_mdify_info(T_FLAG);break;case 5:save(T_FLAG ,N);printf(" 按 Enter 返回上一級菜單!n");getchar()

28、;getchar();adm_nextmenu();break;default:printf("error!n");getchar();getchar();main_menu();/change psword for admvoid a_updt_myinfo()int ch;system("clear");gettime();printf("tttt*n");printf("nntt#n");printf("tt=1.修改密碼=n");printf("tt=n");prin

29、tf("tt=n");printf("tt=2.返回上一級=n");printf("tt=3.返回主菜單=n");printf("tt#nn");printf(" 請輸入您選擇的代號:");scanf("%d",&ch);switch(ch)case 1:a_chpsword();gettime();break;case 2:printf(" 按 Enter 鍵返回上一級菜單!n");getchar();getchar();adm_nextmenu

30、();break;case 3:printf(" 按 Enter 返回主菜單!n");getchar();getchar();main_menu();break;default:printf("error!n");getchar();getchar();main_menu();void a_add_stuinfo()gettime();STU *stud;int i = 0;int stu_nu = 0;FILE *fp=NULL;int j=0;printf(" 您要創建多少個學生的信息:n");scanf("%d&quo

31、t;,&stu_nu);while(i<stu_nu)stud=(STU*)malloc(sizeof(STU);strcpy(stud->STU_psword,"000");/ 初始密碼為000for(j=0;j<3;j+)strcpy(stud->subjecti.SUB_csname),"");(stud->subjecti).SUB_csscore=0;(stud->subjecti).SUB_notesi=0.0;printf(" 輸入第 %d 個學生的信息:n",i+1);pri

32、ntf(" 學生姓名 :n");scanf("%s",stud->STU_name);printf(" 學號: n");scanf("%d",&stud->STU_id);printf(" 年齡: n");scanf("%d",&stud->STU_age);printf(" 年級: n");scanf("%d",&stud->STU_grade);i+;list_add(&(st

33、ud->list),&stu);stu_sort();show(S_FLAG);void a_add_tecinfo()gettime();TEC *tech;TEC *point=NULL;int i = 0;int tech_nu = 0;FILE *fp=NULL;printf(" 您要創建多少個老師的信息:n");scanf("%d",&tech_nu);while(i<tech_nu)tech=(TEC*)malloc(sizeof(TEC);strcpy(tech->TCH_psword,"000&

34、quot;);/初始密碼為000printf(" 輸入第 %d 個老師的信息:n",i+1);printf(" 姓名 :n");scanf("%s",tech->TCH_name);printf(" 工號: n");scanf("%d",&tech->TCH_id);printf(" 教師所授科目:n");scanf("%s",&tech->subject0);i+;list_add(&(tech->list

35、),&tec);show(T_FLAG);void a_seek_stuinfo()int ch;struct list_head *postion=NULL;STU *spoint;system("clear");gettime();printf("tt#n");printf("tt=1. 按學號或姓名查找=n");printf("tt=2.顯示所有學生信息=n");printf("tt=3.返回上一級菜單=n");printf("tt=4.返回主菜單=n");pr

36、intf("tt#n");printf(" 請輸入您選擇的序號:n");scanf("%d",&ch);switch(ch)case 1 : a_seek_info(S_FLAG);break;case 2 :show(S_FLAG);break;case 3 : printf(" 按 Enter 鍵返回上一級!n");getchar();getchar();a_updt_stuinfo();break;case 4 : printf(" 按 Enter 主菜單! n");getchar

37、();getchar();main_menu();break;default : printf("error!");getchar();main_menu();void a_seek_tecinfo()int ch;system("clear");gettime();printf("tt#n");printf("tt=1. 按工號或姓名查找=n");printf("tt=2.顯示所有教師信息=n");printf("tt=3.返回上一級菜單=n");printf("

38、tt=4.返回主菜單=n");printf("tt#n");printf(" 請輸入您選擇的序號:n");scanf("%d",&ch);switch(ch)case 1 : a_seek_info(T_FLAG);break;case 2 :show(T_FLAG);break;case 3 : printf(" 按 Enter 鍵返回上一級!n");getchar();getchar();a_updt_tecinfo();break;case 4 : printf(" 按 Enter

39、 返回主菜單!n");getchar();getchar();main_menu();break;default : printf("error!");getchar();main_menu();/ 更改管理員密碼void a_chpsword()FILE *fp;char psword6;char admusename8;/ 用戶名if(fp=fopen("psword.txt","r")=NULL)printf("sorry,there are nothing!n");getchar();getcha

40、r();a_updt_myinfo();elseprintf(" 請輸入您的用戶名:n");scanf("%s",admusename);printf(" 請輸入您的新密碼:n");scanf("%s",psword);if(!strcmp(use0.ADM_usename,admusename)strcpy(use0.ADM_psword,psword);fclose(fp);save(A_FLAG ,N);printf(" 修改成功! n");getchar();getchar();adm_

41、nextmenu();void a_seek_info(char flag)struct list_head *postion=NULL;STU *spoint;TEC *tpoint;int sid;int tid;switch(flag)case 's':printf(" 請輸入學生學號:n");scanf("%d",&sid);printf(" 按學號顯示學生信息!n");list_for_each(postion,&stu)spoint=list_entry(postion,STU,list);

42、if(sid=spoint->STU_id)printf("tt學號:%dt 姓名:%st 年齡:%dt 年級:%dt 名次 :%dt總分:%f密碼 : %sn",spoint->STU_id,spoint->STU_name,spoint->STU_age,spoint->STU_grade,spoint->S TU_place,spoint->STU_totalscore,spoint->STU_psword);printf("printf("科目信息: n");tt科目一:%st科目二:%s

43、t科 目三: %stn",spoint->subject0.SUB_csname,spoint->subject1.SUB_csname,spoint->subject2.SUB_csname);printf("ntt科目一分數: %dt科目二分數:%dt 科目三分數: %dtn",spoint->subject0.SUB_notes0,spoint->subject1.SUB_notes1,spoint->subject2 .SUB_notes2);printf("ntt*_*_*n");printf(&q

44、uot;tt 總分: %f",(spoint->subject0.SUB_notes0+spoint->subject1.SUB_notes1+spoint->subject2. SUB_notes2)/3.0);break;printf(" 按 Enter 鍵返回上一級!n");getchar();getchar();adm_nextmenu();break;case 't':printf(" 請輸入老師工號:n");scanf("%d",&tid);printf("按老

45、師工號顯示老師信息!n");list_for_each(postion,&tec)tpoint=list_entry(postion,TEC,list);if(tpoint->TCH_id=tid)printf("nntt*_*_*nn");printf("tt工號%dt姓名:%st密碼: %sn",tpoint->TCH_id,tpoint->TCH_name,tpoint->TCH_psword);printf(" 科目信息:n");printf("ntt%sn",tp

46、oint->subject0.SUB_csname);printf("ntt學分: %dn",tpoint->subject0.SUB_csscore);break;printf(" 按 Enter 鍵返回上一級!n");getchar();getchar();adm_nextmenu();break;default :printf("error!n");getchar();getchar();adm_nextmenu();void a_del_info(char flag)struct list_head *postion=NULL;STU *spoint;STU *stud;TEC *tpoint;int s;int t;int sid;int tid;char sname32;char tname32;switch(flag)system("clear");gettime();case 's':printf("tt+ 刪除學生信息!+n");printf("t

溫馨提示

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

評論

0/150

提交評論