学生选课管理系统全源代码Linux环境.docx
《学生选课管理系统全源代码Linux环境.docx》由会员分享,可在线阅读,更多相关《学生选课管理系统全源代码Linux环境.docx(66页珍藏版)》请在冰豆网上搜索。
学生选课管理系统全源代码Linux环境
//*************************************************************
//*********************************************************
//list.h文件
#ifndef_LIST_H
#define_LIST_H
#define_INLINE_staticinline
structlist_head{
structlist_head*next,*prev;
};
#defineLIST_HEAD_INIT(name){&(name),&(name)}
#defineLIST_HEAD(name)\
structlist_headname=LIST_HEAD_INIT(name)
#defineINIT_LIST_HEAD(ptr)do{\
(ptr)->next=(ptr);(ptr)->prev=(ptr);\
}while(0)
_INLINE_void__list_add(structlist_head*add,
structlist_head*prev,
structlist_head*next)
{
next->prev=add;
add->next=next;
add->prev=prev;
prev->next=add;
}
_INLINE_voidlist_add(structlist_head*add,structlist_head*head){
__list_add(add,head,head->next);
}
_INLINE_voidlist_add_tail(structlist_head*add,structlist_head*head)
{
__list_add(add,head->prev,head);
}
_INLINE_void__list_del(structlist_head*prev,structlist_head*next)
{
next->prev=prev;
prev->next=next;
}
_INLINE_voidlist_del(structlist_head*entry)
{
__list_del(entry->prev,entry->next);
}
_INLINE_voidlist_del_init(structlist_head*entry)
{
__list_del(entry->prev,entry->next);
INIT_LIST_HEAD(entry);
}
_INLINE_intlist_empty(structlist_head*head)
{
returnhead->next==head;
}
_INLINE_voidlist_splice(structlist_head*list,structlist_head*head)
{
structlist_head*first=list->next;
if(first!
=list){
structlist_head*last=list->prev;
structlist_head*at=head->next;
first->prev=head;
head->next=first;
last->next=at;
at->prev=last;
}
}
#definelist_entry(ptr,type,member)\
((type*)((char*)(ptr)-(unsignedlong)(&((type*)0)->member)))
#definelist_for_each(pos,head)\
for(pos=(head)->next;pos!
=(head);pos=pos->next)
#definelist_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_HEAD_H_
#define_HEAD_H_
#include
#include"list.h"
#include
#include
#include
#defineY'y'
#defineN'n'
#defineA_FLAG'a'
#defineS_FLAG's'
#defineT_FLAG't'
externstructlist_headstu;//
externstructlist_headtec;//
//科目信息
typedefstructsubject_info
{
floatSUB_notes[3];//科目成绩
intSUB_csscore;//科目学分
charSUB_csname[32];//科目名称
structlist_headlist;
}SUB;
//学生信息
typedefstructSTU_info
{
floatSTU_totalscore;//总分
intSTU_id;//学号
intSTU_age;//年龄
intSTU_grade;//年级
intSTU_place;//名次
charSTU_name[32];//姓名
charSTU_psword[32];//密码
SUBsubject[3];
structlist_headlist;
}STU;
//教师信息:
typedefstructTCH_info
{
intTCH_id;//工号
charTCH_name[32];//姓名
charTCH_psword[32];//密码
SUBsubject[1];
structlist_headlist;
}TEC;
//管理员信息
typedefstructADM_info
{
charADM_usename[8];
charADM_psword[6];
}ADM;
ADMuse[1];
voidgettime();//获取当前时间
voidmain_menu();//主菜单
voidstu_login();//学生登录
voidopenf(char*filename);//判断文件是否存在
voidtec_login();//老师登录
voidadm_login();//管理员登录
voidadm_nextmenu();//管理员2级菜单
voida_updt_stuinfo();//操作学生信息
voida_updt_tecinfo();//操作老师信息
voida_updt_myinfo();//操作管理员自身信息
voida_add_stuinfo();//添加学生信息
voida_add_tecinfo();//添加老师信息
voida_mdify_stuinfo();//修改学生信息
voida_del_info(charflag);//删除信息
voida_mdify_tecinfo();//修改老师信息
voida_seek_stuinfo();//查找学生信息
voida_seek_tecinfo();//查找老师信息
voidshow(charflag);//显示信息
voidsave(charflag,charsystem);//保存信息
voidcheck(charflag);//验证密码
voidcommom();//公用函数集合
voida_show(charflag);//显示信息
voida_seek_info(charflag);//查找信息
voida_mdify_info(charflag);//修改学生或老师信息
voidstu_nextmenu(inttmpid);//学生菜单
voidtec_nextmenu(inttmpid);//老师菜单
voids_show_myinfo(inttmpid);//学生显示自己信息
voidt_show_myinfo(inttmpid);//教师显示自己信息
voids_updt_myinfo(inttmpid);//学生更新自己信息
voids_select_subject(inttmpid);//学生选课
voidt_updt_stuinfo(inttmpid);//教授更新自己信息
voidt_updt_myinfo(inttmpid);//教授显示自己信息
voidreadf();//从文件中读取信息
voidstu_sort();
floatave(floatcore[3]);
float(*f)(floatcore[3]);
intinputpsword(char*pass);
voida_chpsword();
#endif
//*************************************************************************
//***********************************************************************
//入口main函数
#include
#include
#include
#include
#include"head.h"
LIST_HEAD(stu);
LIST_HEAD(tec);
intmain()
{
readf();
system("clear");
printf("\t\t\t**\t\t*\n\
**\t\t*Copyright(c)2010,易嵌教育\n\
**\t\t*Allrightsreserved.\n\
**\t\t*\n\
**\t\t*软件名称:
学生选课管理系统\n\
**\t\t*摘要:
\n\
**\t\t*\n\
**\t\t*当前版本:
1.1\n\
**\t\t*作者:
关仁杰\n\
**\t\t*完成日期:
2010年8月2日\n\
**\t\t*\n");
//voiddelay(unsingedint)
sleep
(2);
main_menu();
return0;
}
voidmain_menu()
{
intch;
charhc;
system("clear");
gettime();
printf("\t\t\t==学生信息管理系统==\n\n");
printf("\t\t###############################################\n");
printf("\t\t==*欢迎使用本系统\a*==\n");
printf("\t\t###############################################\n\n");
printf("\t\t++++++++++++++++++++++++++++++++++++++++++++++++++\n");
printf("\t\t==1.学生==\n");
printf("\t\t==2.教师==\n");
printf("\t\t==3.管理员==\n");
printf("\t\t==4.退出==\n");
printf("\t\t++++++++++++++++++++++++++++++++++++++++++++++++++\n");
printf("请输入您选择的序号:
\n");
scanf("%d",&ch);
switch(ch)
{
case1:
printf("您的身份是学生!
\n请登录:
\n");
gettime();
openf("student.txt");
check(S_FLAG);
break;
case2:
printf("您的身份是教师!
\n请登录:
\n");
gettime();
openf("teacher.txt");
check(T_FLAG);
break;
case3:
printf("您的身份是管理员!
\n请登录\n");
gettime();
adm_login();
break;
case4:
printf("\n");
printf("\a\a\a您已经保存相应的数据了吗?
(yorn)\n");
getchar();
scanf("%c",&hc);
if((hc=='y')||(hc=='Y'))
{
printf("谢谢您使用本系统,如有需要请联系:
QQ:
……\n");
printf("请按Enter键退出!
\n");
getchar();
getchar();
exit(0);
}
elseif((hc=='n')||(hc=='N'))
{
printf("您还没有保存,系统将为您自动保存!
\n");
save(S_FLAG,Y);
}
break;
default:
printf("您的输入有误,请返回上级菜单!
\n");
getchar();
getchar();
main_menu();
}
}
//试读文件,验证是否建立
voidopenf(char*filename)
{
FILE*fp;
if((fp=fopen(filename,"r"))==NULL)
{
filename=NULL;
printf("对不起!
还没有建立相应的信息!
\n请于管理员联系!
\n");
getchar();getchar();
main_menu();
}
fclose(fp);
}
//管理员登录
voidadm_login()
{
charpsword[6];
FILE*fp;
inti=0;
if((fp=fopen("psword.txt","r"))==NULL)
{
printf("对不起没有相应的信息,请您建立!
\n");
printf("请输入您的用户名(不得多于8:
个字符):
\n");
scanf("%s",use[0].ADM_usename);
printf("请输入您的密码:
\n");
while((psword[i]=getchar())!
='\n'||(psword[i]=getchar())!
=EOF||i<6)
{
putchar('*');
i++;
}
strcmp(use[0].ADM_psword,psword);
save(A_FLAG,N);//savetheinfo
main_menu();
}
else
{
check(A_FLAG);
}
fclose(fp);
}
//****************************************************************
//****************************************************************
//************************************
//管理员相关函数
#ifndef_ADM_nextmenu_c
#define_ADM_nextmenu_c
#include
#include
#include
#include"head.h"
structlist_head*postion;
voidadm_nextmenu()
{
intch;
system("clear");
gettime();
printf("\t\t\t\t****************\n");
printf("\n\n\t\t###################################\n");
printf("\t\t==1.更改学生信息==\n");
printf("\t\t==2.更改老师信息==\n");
printf("\t\t==3.更改自己信息==\n");
printf("\t\t==4.返回主菜单==\n");
printf("\t\t###################################\n\n");
printf("请输入您选择的代号:
");
scanf("%d",&ch);
switch(ch)
{
case1:
a_updt_stuinfo();
break;
case2:
a_updt_tecinfo();
break;
case3:
a_updt_myinfo();
break;
case4:
printf("按Enter键返回主菜单!
\n");
getchar();
getchar();
main_menu();
break;
default:
printf("error!
\n");
getchar();
getchar();
main_menu();
}
}
//updateinfo
voida_updt_stuinfo()
{
intch;
system("clear");
gettime();
printf("\t\t\t\t****************\n");
printf("\n\n\t\t###################################\n");
printf("\t\t==1.添加学生信息==\n");
printf("\t\t==2.删除学生信息==\n");
printf("\t\t==3.查找学生信息==\n");
printf("\t\t==4.修改学生信息==\n");
printf("\t\t==5.返回上一级菜单==\n");
printf("\t\t###################################\n\n");
printf("请输入您选择的代号:
");
scanf("%d",&ch);
switch(ch)
{
case1:
a_add_stuinfo();
break;
case2:
a_del_info(S_FLAG);
break;
case3:
a_seek_stuinfo();
break;
case4:
a_mdify_info(S_FLAG);
break;
case5:
save(S_FLAG,N);
printf("按Enter返回上一级菜单!
\n");
getchar();
getchar();
adm_nextmenu();
break;
default:
printf("error!
\n");
getchar();
getchar();
main_menu();
}
}
//updateinfo
voida_updt_tecinfo()
{
intch;
system("clear");
gettime();
printf("\t\t\t\t****************\n");
printf("\n\n\t\t###################################\n");