h>
#defineselectint
typedefstruct//账户信息
{
charname[20];//User。
name
charpw[20];//User。
pw
}User;
typedefstruct
{
charNum[20];
charn1[20];
charClass[20];
chartime[100];
charreason[100];
charinstructor[100];
}Leave;
typedefstruct
{
charn1[20];
charNum[20];
//charname[20];
charClass[20];
chartime[100];
charreason[100];
charinstructor[100];
charsuggest[100];
}TEACHER;
intcheck(charname[20])
{
inti=0;
Userru;
FILE*f=fopen(”data。
dat”,"rb”);
rewind(f);
for(i=0;!
feof(f);i++)
{
intd=i*sizeof(User);
fseek(f,d,SEEK_SET);
fread(&ru,sizeof(User),1,f);
if(strcmp(name,ru.name)==0)
return1;
}
return-1;
}
intlogin(charname[20],charpw[20])
{
Userus;
FILE*f=fopen(”data.dat”,”rb”);
while(!
feof(f))
{
fread(&us,sizeof(User),1,f);
if(strcmp(name,us。
name)==0)
{
if(strcmp(pw,us。
pw)==0)return1;
}
}
return-1;
}
intmain()
{
charn[20];
charplog[20];
charnlog[20];
intc;
Useru;
FILE*f=fopen("data.dat”,”ab");
if(f!
=NULL)
{
fwrite(&u,sizeof(User),1,f);
}
fclose(f);
Login:
system(”colorF0");
system("cls”);
printf(”\n\n");
printf(”========================================================================\n”);
printf("||\n”);
printf("|—-—--———-————————--—————————-学生请假系统---—-——-—---—————-———--—--———|\n”);
printf("||\n");
printf(”========================================================================\n");
printf(”\n”);
Sleep(1000);
printf(”\n");
printf(”请输入帐号:
”);
scanf("%s",nlog);
c=check(nlog);
if(c==1)//如果账户存在
{
strcpy(n,nlog);//复制登录帐号
if(strlen(n)==9)//如果是学生
{
inta,i;
selects=0;
printf(”\n”);
printf(”请输入密码:
");//直接输入密码
scanf("%s”,plog);
for(a=2,i=0;i<4;i++,a—-)
{
if(login(nlog,plog)==—1)//密码错误
{
system(”colorF0”);
charplog[20]={};//登录数组初始化
system("cls");
printf("\n”);
printf(”************************************************************************\n”);
printf(”*密码错误!
*\n");
printf("************************************************************************\n");
printf(”\n\n”);
if(a>0)
{
printf(”请重新输入密码(你还有%d次机会):
”,a);
printf("\n\n”);
scanf("%s”,plog);
if(login(nlog,plog)==1)
gotosuccess2;
}
else
return0;
}
}
if(login(nlog,plog)==1)
{
success2:
system(”colorF0”);
printf("\n\n");
printf("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\登陆成功///////////////////////\n”);
Sleep(1000);
system("cls");
}
LEAVESYSTEM:
printf("\n\n”);
printf(”========================================================================\n");
printf(”|1。
提交请假申请|\n");
printf(”|2。
查询请假批准状态|\n");
printf(”|如无需操作,可直接关闭程序|\n”);
printf(”========================================================================\n");
printf(”\n\n”);
Sleep(1000);
printf("请输入您要执行的选项:
”);
scanf(”%d”,&s);
Sleep(1000);
while(s!
=1&&s!
=2)
{
if(s!
=1&&s!
=2)
{system("color0c");
printf("选项不存在,请重新输入(1/2):
”);
s=0;
scanf(”%d”,&s);
}
}
if(s==1)//写入请假
{
system("colorF0”);
system(”cls");
printf("\n\n”);
printf(”========================================================================\n”);
printf("||\n");
printf(”|-—--———--——————---——-——--———-—提交请假申请—--—-———---—--——-—-——-——--——|\n”);
printf(”||\n");
printf(”========================================================================\n”);
printf(”\n\n”);
Leavea;
Sleep(1000);
printf("请输入班级:
\n”);
scanf("%s",a。
Class);
printf(”请输入姓名:
\n");
scanf(”%s”,a.n1);
printf(”请详细输入请假时间:
\n”);
scanf("%s”,a。
time);
printf(”请详细输入请假原因:
\n”);
scanf(”%s”,a。
reason);
strcpy(nlog,a。
Num);
strcpy(a.instructor,"0”);
FILE*t=fopen("leave。
dat”,"ab”);
fwrite(&a,sizeof(Leave),1,t);//讲以变量u的地址开始的内存区域的一个数据写到f指向的文件中,每个数据占sizeof(User)
fclose(t);
fflush(t);
//Sleep(1000);
printf(”\n”);
printf(”\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\保存成功///////////////////////\n”);
printf(”请不定时来查询你的假条申请状态!
\n\n\n");
system("pause”);
system(”cls");
gotoLEAVESYSTEM;
}
if(s==2)//学生查询状态代码
{
system(”colorF0”);
system("cls”);
printf("\n\n”);
printf(”========================================================================\n”);
printf(”||\n”);
printf("|--——————-——-—-——-—————--———-查询请假批准状态-———————-————-—————-—-—--—|\n");
printf(”||\n”);
printf(”========================================================================\n”);
Sleep(1000);
TEACHERb;
FILE*t=fopen("read.dat”,”rb”);
while
(1)
{
if(!
(fread(&b,sizeof(TEACHER),1,t)))
break;
if((strcmp(nlog,b。
Num))==0)
{
printf("—-—-—--—-————--—--—————----——--————--—-—-————--———-——-—-———-—-—\n”);
printf(”|学生%s请假申请反馈信息:
\n”,b。
n1);
printf("|班级:
%s\n\n”,b。
Class);
printf("|姓名:
%s\n\n",b。
n1);
printf(”|请假时间:
%s\n\n”,b。
time);
printf(”|请假原因:
%s\n\n”,b。
reason);
printf(”—--—--—————-—-—-——————————--———-——-——-————---—-—--——-———-————-—\n”);
Sleep(1000);
printf("\n");
printf(”-—————-—--——--———-—————-——--—--———-———-————-——-———————-—-————\n");
printf(”申请状态:
%s\n",b。
instructor);
printf("辅导员意见:
%s\n",b.suggest);
printf(”—-———-——-—————-————------————-—-——-—-———----——————-————----——\n");
system(”pause”);
Sleep(1000);
system("cls”);
gotoLEAVESYSTEM;
}
}
}
if(s==3)
{
gotoLogin;
}
}//身份学生
if(strlen(n)==4)//如果是辅导员
{
inta,i;
selects;
printf("\n”);
printf(”请输入密码:
”);//直接输入密码
scanf("%s”,plog);
for(a=2,i=0;i<4;i++,a——)
{
if(login(nlog,plog)==—1)//密码错误
{
system(”color0c”);
charplog[20]={};//登录数组初始化
system(”cls”);
printf("\n”);
printf(”************************************************************************\n”);
printf(”*密码错误!
*\n”);
printf(”************************************************************************\n”);
printf(”\n\n”);
if(a〉0)
{
printf(”请重新输入密码(你还有%d次机会):
",a);
printf(”\n\n");
scanf("%s”,plog);
if(login(nlog,plog)==1)
gotosuccess3;
}
else
return0;
}
}
if(login(nlog,plog)==1)
{
success3:
system("colorF0”);
printf(”\n\n");
printf("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\登陆成功///////////////////////\n”);
Sleep(1000);
}
//Approvalsystem:
system(”cls”);
printf("\n\n”);
printf(”========================================================================\n”);
printf("||\n");
printf(”|—-————————--———————-——-—-学生请假系统(辅导员端)—--———--——--—--——-—-———|\n”);
printf(”||\n”);
printf(”========================================================================\n”);
printf("\n");
Sleep(1000);
printf(”========================================================================\n”);
printf(”|1。
查看学生请假申请|\n”);
printf(”|2。
返回登陆界面|\n”);
printf(”|如无需操作,可直接关闭程序|\n");
printf(”========================================================================\n");
printf(”\n\n”);
Sleep(1000);
printf(”请输入您要执行的选项:
”);
scanf(”%d”,&s);
while(s!
=1&&s!
=2)
{
if(s!
=1&&s!
=2)
{
printf(”选项不存在,请重新输入(1/2):
”);
scanf(”%d”,&s);
}
}
if(s==1)//辅导员读
{
system("cls”);
printf("\n\n”);
printf(”========================================================================\n");
printf(”||\n”);
printf(”|-———--——-—-—--———-———-—--———查看学生请假申请——-—-——-—-—-—-————————-———|\n”);
printf("||\n");
printf(”========================================================================\n”);
printf(”\n\n”);
Sleep(1000);
Leavea;
FILE*t=fopen("leave.dat”,”rb");
while
(1)
{
intch;
if(!
(fread(&a,sizeof(Leave),1,t)))
break;
{
printf(”---——---—--—--—-—-————-————————————-—--—-—————--—————-———-—--\n");
printf("|学生信息如下:
\n”);
printf(”|班级:
%s\n”,a。
Class);
printf(”|姓名:
%s\n",a。
n1);
printf("|学号:
%s\n”,a。
Num);
printf(”|请假时间:
%s\n”,a。
time);
printf("|请假原因:
%s\n”,a.reason);
printf("—----—-——-———-—-——---——-——-——-——-——————-———-——-——-—-——-—---—-\n”);
Sleep(1000);
printf(”\n\n\n");
printf(”\n”);
printf("是否批准学生请假申请\n”);
printf(”————---——————-—-—---——--—-————-———--—--—-—-—-—-——--——————-—\n”);
printf("————-----—-——-——-———--—-—-—--————--————-—-—-—-—————---———--\n");
printf(”1.批准学生请假申请\n”);
printf(”2。
不批准学生请假申请\n”);
printf("\n\n\n");
printf(”请输入您要执行的选项:
”);
scanf(”%d",&ch);
while(ch!
=1&&ch!
=2)
{
if(ch!
=1&&ch!
=2)
{
printf(”选项不存在,请重新输入(1/2):
");
scanf("%d”,&ch);
}
}
if(ch==1)
{
printf("\n\n");
printf("-——-—-—-----——-—-———-——-—---—-———--————-————-——————-—-—————--\n");
printf("执行中.。
。
.\n");
printf(”——-—-—-———-—————-—---—-—————-—-———————----———-—-——-——-—-——-——\n");
Sleep(1000);
TEACHERb;
FILE*F=fopen(”read.dat”,”ab”);
strcpy(b.instructor,"您的请假申请已被批准!
");
printf(”\n");
printf(”辅导员意见:
”);
scanf(”%s”,b。
suggest);
strcpy(b。
Class,a。
Class);
strcpy(b。
n1,a。
n1);
strcpy(b.time,a.time);
strcpy(b。
reason,a。
reason);
strcpy(b。
Num,a。
Num);
//FILE*f3=fopen("leave。
dat”,”ab");
fwrite(&b,sizeof(TEACHER),1,F);
fclose(F);
fflush(F);
Sleep(1000);
printf(”\n\n\n");
printf(”\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\操作成功///////////////////////\n”);
system(”pause”);
printf(”\n\n\n\n\n”);
continue;
}
if(ch==2)
{
printf("-———————--——————————--——-——-——-—-—---—-——————--——————————-———\n");
printf(”执行中...。
\n”);
printf(”-—-————-———---————-——---——-———--————-—-——-—————----——————--——\n”);
Sleep(1000);
TEACHERb;
FILE*F=fopen(”read.dat”,"ab”);
strcpy(b。
instructor,”您的请假申请没有被批准,请按时上课!
”);
printf(”\n”);
printf(”辅导员意见:
”);
scanf("%s”,b。
suggest);
strcpy(b。
Class,a。
Class);
strcpy(b.n1,a。
n1);
strcpy(b。
time,a。
time);
strcpy(b。
reason,a。
reason);
strcpy(b。
Num,a.Num);
fwrite(&b,sizeof(TEACHER),1,F);
fclose(F);
fflush(F);
Sleep(1000);
printf("\n\n\n");
printf("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\操作成功///////////////////////\n”);
system(”pause”);
printf(”\n\n\n\n\n”);
continue;
}
}
}
}
if(s==2)
{
system(”cls”);
gotoLogin;//修改学生请假申请状态反回
}
}//如果是辅导员
if(strlen(n)==5)//如果是老师
{
inta,i;
printf(”\n”);
printf("请输入密码:
");//直接输入密码
scanf(”%