#include<stdio.h>
#include<string.h>
#include<stdlib.H>
struct wo//员工信息结构体
{
int num;
char name[12];
int date1;
int date2;
int date3;
int date4;
}person[100];
struct room//房间信息结构体
{
int number;
char type[15];
char now;
int date1;
int date2;
}read[100];
struct cai//菜信息的结构体
{
char name[12];
int number;
int price;
}can[100];
int number,number1,number2,i;
//--------------------------------------------------基层函数-------------------------------------------------
//---------------------------------密码
int check(int w)//核对密码
{
FILE *fp;int mi,s;
switch(w)
{
case 1:fp=fopen("mimaz.txt","rb"); if((fp=fopen("mimaz.txt","rb"))==NULL){printf("未创建密码\n");}break;
case 2:fp=fopen("mimazf.txt","rb"); if((fp=fopen("mimazf.txt","rb"))==NULL){printf("未创建密码\n");}break;
case 3:fp=fopen("mimazh.txt","rb"); if((fp=fopen("mimazh.txt","rb"))==NULL){printf("未创建密码\n");}break;
}
fread(&s,sizeof(int),1,fp);
fclose(fp);
printf("请输入密码\n");
scanf("%d",&mi);
system("cls");
if(mi==s)
return 2;
else
{
printf("密码输入错误,请重试\n");
return 0;
}
}
void change(int w)//修改密码
{
FILE *fp;int s,d;
switch(w)
{
case 1:fp=fopen("mimaz.txt","wb"); if((fp=fopen("mimaz.txt","wb"))==NULL) printf("无法创建密码文件\n");break;
case 2:fp=fopen("mimazf.txt","wb"); if((fp=fopen("mimazf.txt","wb"))==NULL) printf("无法创建密码文件\n");break;
case 3:fp=fopen("mimazh.txt","wb"); if((fp=fopen("mimazh.txt","wb"))==NULL) printf("无法创建密码文件\n");break;
}
if(check(w)==2)
{
printf("请输入新密码\n");
scanf("%d",&s);system("cls");
printf("请输入确认新密码\n");
scanf("%d",&d);system("cls");
if(s==d)
{
fwrite(&s,sizeof(int),1,fp);
fclose(fp);
printf("密码修改成功\n");
}
}
}
int panduan(int a)//密码开关,返回:0关闭密吗1则开启
{
FILE *fp;int i;
switch(a)
{
case 1:fp=fopen("panduanz.txt","rb");if((fp=fopen("panduanz.txt","rb"))==NULL) fp=fopen("panduanz.txt","wb");break;
case 2:fp=fopen("panduanzf.txt","rb");if((fp=fopen("panduanzf.txt","rb"))==NULL) fp=fopen("panduanzf.txt","wb");break;
case 3:fp=fopen("panduanzh.txt","rb");if((fp=fopen("panduanzh.txt","rb"))==NULL) fp=fopen("panduanzh.txt","wb");break;
}fread(&i,sizeof(int),1,fp);
if(i==1)
return 1;
else return 0;
fclose(fp);
}
void xiugai(int a)//改变密码状态
{
FILE *fp;
int i;
printf("输入1开启密码,输入其他任意数关闭密码\n");
scanf("%d",&i);
switch(a)
{
case 1:fp=fopen("panduanz.txt","wb");break;
case 2:fp=fopen("panduanzf.txt","wb");break;
case 3:fp=fopen("panduanzh.txt","wb");break;
}
fwrite(&i,sizeof(int),1,fp);
if(i==1)
printf("密码启用成功\n");
else
printf("关闭密码成功\n");
fclose(fp);
}
//-----------------------------------------------------------------------------------输入输出
void scwork()//输入员工信息
{
scanf("%d %s %d %d %d %d",&person[i].num,person[i].name,&person[i].date1,
&person[i].date2,&person[i].date3,&person[i].date4);
}
void prwork()//输出员工信息
{
printf("%d:工号%d 名字%s %d号 %d号 %d号 %d号\n",i,person[i].num,person[i].name,
person[i].date1,person[i].date2,person[i].date3,person[i].date4);
}
void scroom()//输入房间信息
{
scanf("%d %s %c %d%d",&read[i].number,read[i].type,
&read[i].now,&read[i].date1,&read[i].date2);
}
void prroom()//输出房间信息
{
printf("%d:房号%d 类型%s 状态%c 入住日期%d号 退房日期%d号\n",i,read[i].number,
read[i].type,read[i].now,read[i].date1,read[i].date2);
}
void sccai()//输入菜谱信息
{scanf("%s %d %d",can[i].name,&can[i].price,&can[i].number);}
void prcai()//输出菜谱信息
{
printf("%d: %s %d元 %d\n",i,can[i].name,can[i].price,can[i].number);
}
void head()//总经理
{
system("cls");
printf("|------------------------------------------------------------------|\n");
printf("|* ************欢迎来到森森饭店管理系统************ *|\n\n");
printf("|* ************************************************ *|\n\n");
printf("|------------------------------------------------------------------|\n\n");
}
//---------------------------------------------------------------------------员工信息
void numbe()// 读取员工数
{
FILE *fx;
fx=fopen("number.tx","rb");
if((fx=fopen("number.txt","rb"))==NULL)
{
fx=fopen("number.txt","wb");
number=0;
printf("仍未创建资料,请输入资料\n");
}
else
fread(&number,sizeof(int),1,fx);
}
void readwork()// 读取员工信息
{
FILE *fp;
fp=fopen("staff.txt","rb");
if((fp=fopen("staff.txt","rb"))==0)
{
printf("文件打不开,或未创建\n");
}
else
{
numbe();
for(i=0;i<number;i++)
fread(&person[i],sizeof(struct wo),1,fp);
fclose(fp);
}
}
void savework()//保存员工信息
{
FILE *fp,*fn;
fp=fopen("staff.txt","wb");
for(i=0;i<number;i++)
fwrite(&person[i],sizeof(struct wo),1,fp);
fclose(fp);
fn=fopen("number.txt","wb");
fwrite(&number,sizeof(int),1,fn);
fclose(fn);
}
void arragework()//重置员工信息
{
printf("输入您想要安排的人员个数\n");
scanf("%d",&number);
printf("工号 姓名 每月休息日期1: 2: 3: 4: \n");
for(i=0;i<number;i++)
scwork();
savework();
}
void addwork()//增加员工信息
{
int a;
printf("增加插入个数:");
scanf("%d",&a);number=number+a;
printf("工号 姓名 每月休息日期1: 2: 3: 4:\n");
for(i=number-a;i<number;i++)
scwork();
savework();
printf("增加成功\n");
}
void searchname()//按照名字查询
{
char name[12];int r=0;
printf("请输入名字\n");
scanf("%s",name);
for(i=0;i<number;i++)
if(strcmp(person[i].name,name)==0)
{
r=1;
prwork();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchnum()//按照工号查询
{
int num;int r=0;
printf("请输入num\n");
scanf("%d",&num);
for(i=0;i<number;i++)
if(person[i].num==num)
{
r=1;
prwork();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchday()//按照休息日期查询
{
int num;int r=0;
printf("请输入日期\n");
scanf("%d",&num);
for(i=0;i<number;i++)
if(person[i].date1==num||person[i].date2==num||person[i].date3==num||person[i].date4==num)
{
r=1;
prwork();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchwork()//收索员工信息
{
do{
printf("请输入收索方式:\n 按名字:1 按工号:2 按休息日期:3 结束查询:4\n");
scanf("%d",&i);
switch(i)
{case 1:searchname();break;
case 2:searchnum();break;
case 3:searchday();break;
case 4:break;
default:printf("输入错误,请重新输入\n");break;
}
}while(i!=4);
}
void seeallwork()//查看员工休息日期
{
for(i=0;i<number;i++)
prwork();
}
void delework()//删除员工信息
{
int s;
printf("输入删除的序号\n");
scanf("%d",&i);
number=number-1;
prwork();
printf("确认删除?确认:1 取消:2");
scanf("%d",&s);
if(s==2)
system("pause");
for(i=i;i<number;i++)
person[i]=person[i+1];
savework();
printf("删除成功\n");
}
void modifywork()//更改员工信息
{
printf("输入修改的序号:");
scanf("%d",&i);printf("更改前:");
prwork();
printf("请更改:");
scwork();
savework();
printf("更改成功\n");
}
//-----------------------------------------------------------------------------------菜菜
void numbe2()//统计存菜信息数
{
FILE *fx;
fx=fopen("number2.tx","rb");
if((fx=fopen("number2.txt","rb"))==NULL)
{
fx=fopen("number2.txt","wb");
number=0;
printf("仍未创建资料,请输入资料\n");
}
else fread(&number2,sizeof(int),1,fx);
}
void readcai()//读取菜的信息
{
FILE *fp;
fp=fopen("cai.txt","rb");
if((fp=fopen("cai.txt","rb"))==NULL)
printf("文件打不开,或未创建\n");
else
{
numbe2();
for(i=0;i<number2;i++)
fread(&can[i],sizeof(struct cai),1,fp);
fclose(fp);
}
}
void savecai()//保存菜的信息
{
FILE *fp,*fn;
fp=fopen("cai.txt","wb");
for(i=0;i<number2;i++)
fwrite(&can[i],sizeof(struct cai),1,fp);
fclose(fp);
fn=fopen("number2.txt","wb");
fwrite(&number2,sizeof(int),1,fn);
fclose(fn);
}
void addcai()//增加菜的信息
{
int a;readcai();
printf("输入增加个数\n");
scanf("%d",&a);number2=number2+a;
printf("菜名 单价 数量\n");
for(i=number2-a;i<number2;i++)
sccai();
savecai();
printf("增加成功\n");
}
void searchnam()//按照菜名查询
{
char name[12];int r=0;
printf("请输入名字\n");
scanf("%s",name);
for(i=0;i<number;i++)
if(strcmp(can[i].name,name)==0)
{
r=1;
prcai();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchnum2()//按照菜的数量
{
int num;int r=0;
printf("请输入num\n");
scanf("%d",&num);
for(i=0;i<number2;i++)
if(can[i].number==num)
{
r=1;
prcai();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchprice()//按照价格查询
{
int num;int r=0;
printf("请输入价格\n");
scanf("%d",&num);
for(i=0;i<number;i++)
if(can[i].price==num)
{
r=1;
prcai();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchcai()//收索菜的信息
{
do
{
printf("请输入收索方式:\n 按菜名:1 按数量号:2 按单价:3 不做任何操作:4\n");
scanf("%d",&i);
switch(i)
{
case 1:searchnam();break;
case 2:searchnum2();break;
case 3:searchprice();break;
case 4:break;
default:printf("输入错误,请重新输入\n");break;
}
}while(i!=4);
}
void seeallcai()//查看所有菜的信息
{
for(i=0;i<number2;i++)
prcai();
}
void delecai()//删除菜的信息
{
printf("输入删除的序号\n");
int s;
scanf("%d",&i);
prcai();
printf("确认删除?确认:1 取消:2");
scanf("%d",&s);
if(s==2)system("pause");
number2=number2-1;
for(i=i;i<number2;i++)
can[i]=can[i+1];
savecai();
printf("删除成功\n");
}
void modifycai()//更改菜的信息
{
printf("输入修改的位置:");
scanf("%d",&i);
printf("更改前:");prcai();
printf("请更改:");sccai();
savecai();printf("更改成功\n");
}
//-----------------------------------------------------------------------------------房间信息
void numbe1()
{
FILE *fx;
fx=fopen("number1.tx","rb");
if((fx=fopen("number1.txt","rb"))==NULL)
{
fx=fopen("number1.txt","wb");
number1=0;
printf("仍未创建资料,请输入资料\n");
}
else fread(&number1,sizeof(int),1,fx);
}
void readroom()
{
FILE *fp;
fp=fopen("room.txt","rb");
if((fp=fopen("room.txt","rb"))==NULL)
printf("文件打不开,或未创建\n");
else
{
numbe1();
for(i=0;i<number1;i++)
fread(&read[i],sizeof(struct room),1,fp);
fclose(fp);
}
}
void saveroom()//安排员工休息日期
{
FILE *fp,*fn;
fp=fopen("room.txt","wb");
for(i=0;i<number1;i++)
fwrite(&read[i],sizeof(struct room),1,fp);
fclose(fp);
if(number1>100)
printf("超过资料存储界限\n");
else
{
fn=fopen("number1.txt","wb");
fwrite(&number1,sizeof(int),1,fn);
fclose(fn);
}
}
void arrageroom()//重置房间信息
{
int s;
printf("输入您想要重置的房间个数(温馨提示您现在的操作会删掉原来的数据:输入0表示取消操作)\n");
scanf("%d",&s);
if(s==0)
printf("已取消该操作\n");
else
{
number1=s;
printf("房号 类型 房间状态(e表示有人住f表示空) 入住日期 退房日期\n");
for(i=0;i<number1;i++)
scroom();
saveroom();printf("重置成功\n");
}
}
void addroom()//重置房间信息
{
int a,s;readroom();
printf("输入插入个数\n");scanf("%d",&a);
printf("输入插入位置\n");scanf("%d",&s);
printf("房号 类型 房间状态(e表示有人住f表示空) 入住日期 退房日期\n");
if(number1+a>100)
printf("超过储存界限\n");
else
{
number1=number1+a;
for(i=number-1;i>s-1;i--)
read[i]=read[i-a];
for(i=s;i<s+a;i++)
scroom();
saveroom();
}
}
void searchlei()//按照房间类型类型查询
{
char name[12];int r=0;
printf("请输入类型\n");
scanf("%s",name);
for(i=0;i<number1;i++)
if(strcmp(read[i].type,name)==0)
{
r=1;
prroom();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchnum1()//按照房间号
{
int num1;int r=0;
printf("请输入num\n");
scanf("%d",&num1);
for(i=0;i<number1;i++)
if(read[i].number==num1)
{
r=1;
prroom();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchday1()//按照日期查询
{
int num1;int r=0;
printf("请输入日期\n");
scanf("%d",&num1);
for(i=0;i<number1;i++)
if(read[i].date1==num1||read[i].date2==num1)
{
r=1;
prroom();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchroom()//房间信息查询
{
do
{
printf("请输入收索方式:\n 按类型:1 按房号:2 按日期:3 结束收索:4\n");
scanf("%d",&i);
switch(i)
{
case 1:searchlei();break;
case 2:searchnum1();break;
case 3:searchday1();break;
case 4:break;
default:printf("输入错误,请重新输入\n");break;
}
}while(i!=4);
}
void seeallroom()//查看所有房间信息
{
for(i=0;i<number1;i++)
prroom();
}
void deleroom()//删除房间信息
{
printf("输入删除的序号\n");
int s;
scanf("%d",&i);
prroom();
printf("确认删除?确认:1 取消:2");
scanf("%d",&s);
if(s==2)
system("pause");
number1=number1-1;
for(i=i;i<number1;i++)
read[i]=read[i+1];
saveroom();
printf("删除成功\n");
}
void modifyroom()//更改房间信息
{
printf("输入更改的序号\n");
scanf("%d",&i);
printf("更改前:");
prroom();
printf("请更改:");
scroom();
saveroom();printf("更改成功\n");
}
//----------------------------------------------------二级菜单-------------------------------------------------
void food(int a)//--------------------------餐饮部1
{
int select,j=0;
readwork();
readcai();
printf("| ------------------------------------ |\n");
printf("|** * 欢迎来到餐饮部 * **|\n\n");
printf("| ------------------------------------ |\n");
if(a==0)
turn1:
{j=1;
do{
printf("请选择功能\n");
printf(" 退出:0 查看所有菜1\n");
printf(" 改菜:2 搜菜:3\n");
printf(" 添加菜4 删除菜5\n");
printf(" 查看所有员工:6 查询个别员工7\n");
if( a==1)
{
printf(" 修改密码:8 启用密码:9\n");
printf(" 添加员工信息10 更改员工信息11\n");
}
scanf("%d",&select);
if(select>7&&a==0)
select=32;
switch(select)
{
case 9:xiugai(2);break;
case 8:change(2);break;
case 6:seeallwork();break;
case 2:modifycai();break;
case 3:searchcai();break;
case 4:addcai();break;
case 5:delecai();break;
case 1:seeallcai();break;
case 11:modifywork();break;
case 10:addwork();break;
case 7:searchwork();break;
case 0:printf("退出餐饮部\n");break;
default:printf("输入错误,请重新输入^U^\n");
}
}while(select!=0);
}
else if(j==0)
{
if(panduan(2)==0)
goto turn1;
else
if(check(2)==2)
goto turn1;
}
}
void hall(int a)//--------------------------前厅2
{
int j=0;
readroom();readwork();
if(a==0)
{
int select;
do
{
retryh: printf("| ---------------------------------- |\n");
printf("|** * 欢迎来到前厅 * **|\n");
printf("| ---------------------------------- |\n");j=1;
printf("请选择相应的功能:\n");
printf(" 退出:0 查看所有房间信息:1\n 房间查询:2 更改房间信息:3\n");
printf(" 查询员工信息:4 查看所有员工信息:5\n");
if(a==1)
{
printf(" 增加房间:6 删除房间:7\n");
printf(" 启用密码:8 修改密码:9\n");
printf(" 增加员工信息:10 更改员工信息:11\n");
printf(" 重置房间信息:12 \n");}
scanf("%d",&select);
if(select>4&&a==0)
select=32;
switch(select)
{
case 8:xiugai(3);break;
case 9:change(3);break;
case 5:seeallwork();break;
case 3:modifyroom();break;
case 7:deleroom();break;
case 2:searchroom();break;
case 6:addroom();break;
case 4:searchwork();break;
case 10:addwork();break;
case 11:modifywork();break;
case 12:arrageroom();break;
case 1:seeallroom();break;
case 0:printf("退出前厅\n");break;
default:printf("*_*输入错误,请重新输入^U^\n");
}
}while(select!=0);
}else if(j==0)
{
if(panduan(3)==0)
goto retryh;
else
if(check(3)==2)
goto retryh;
}
}
//----------------------------------------------------主级菜单--------------------------------------
void menu()//总经理菜单
{
int select;
do
{
readwork();readcai();readroom();
printf("| ---------------------------------- |\n");
printf("|** * 欢迎总经理! * **|\n");
printf("| ---------------------------------- |\n");
printf("请选择功能\n");
printf(" 退出:0 查看所有员工:1\n");
printf(" 查询员工信息2 添加员工:3\n");
printf(" 删除员工信息4 更改员工信息:5\n");
printf(" 查看所有菜6 查询菜7\n");
printf(" 查看房间信息8 收索房间9\n 重置员工安排:10");
printf(" 启用密码:11 \n 修改密码:12\n");
scanf("%d",&select);system("cls");
switch(select)
{
case 11:xiugai(1);break;
case 12:change(1);break;
case 10:arragework();break;
case 1:seeallwork();break;
case 3:addwork();break;
case 2:searchwork();break;
case 4:delework();break;
case 7:searchcai();break;
case 6:seeallcai();break;
case 8:seeallroom();break;
case 9:searchroom();break;
case 5:modifywork();break;
case 0:break;
default:printf("输入错误,请重新输入^U^\n");
}
}while(select!=0);
}
void zjl()//总经理登陆
{
if(panduan(1)==0)
menu();
else if(check(1)==2)
menu();
}
void department(int s)//经理/员工登陆界面
{
int a;
system("cls");
printf("请选择部门:\n");
do
{
printf(" |-----------------------|\n");
printf(" |退出:0 餐饮部:1|\n |前厅:2 |\n");
printf(" |-----------------------|\n");
printf(" 请输入序号:\n");
scanf("%d",&a);
switch(a)
{
case 1:food(s);break;
case 2:hall(s);break;
case 0:break;
default:printf("*_*输入错误,请重新输入^U^\n");
}
}while(a!=0);
}
void main()//主函数
{
int select;
start: head();
printf("请选择登陆身份:\n");
printf(" ----------------------\n");
printf(" |总经理请输入:1 |\n");
printf(" |经理请输入:2 |\n");
printf(" |普通员工请输入:3 |\n");
printf(" |退出:0 |\n");
printf(" ----------------------\n");
scanf("%d",&select);
switch(select)
{
case 1:zjl();goto start;
case 2:department(1);goto start;
case 3:department(0);goto start;
有错误。。。帮忙看一下
--------------------Configuration: adsf - Win32 Debug--------------------
Compiling...
adsf.c
c:\documents and settings\administrator\adsf.c(410) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\adsf.c(414) : error C2065: 's' : undeclared identifier
c:\documents and settings\administrator\adsf.c(573) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\adsf.c(785) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
adsf.obj - 1 error(s), 0 warning(s)
帮忙改下吧大神们
#include<string.h>
#include<stdlib.H>
struct wo//员工信息结构体
{
int num;
char name[12];
int date1;
int date2;
int date3;
int date4;
}person[100];
struct room//房间信息结构体
{
int number;
char type[15];
char now;
int date1;
int date2;
}read[100];
struct cai//菜信息的结构体
{
char name[12];
int number;
int price;
}can[100];
int number,number1,number2,i;
//--------------------------------------------------基层函数-------------------------------------------------
//---------------------------------密码
int check(int w)//核对密码
{
FILE *fp;int mi,s;
switch(w)
{
case 1:fp=fopen("mimaz.txt","rb"); if((fp=fopen("mimaz.txt","rb"))==NULL){printf("未创建密码\n");}break;
case 2:fp=fopen("mimazf.txt","rb"); if((fp=fopen("mimazf.txt","rb"))==NULL){printf("未创建密码\n");}break;
case 3:fp=fopen("mimazh.txt","rb"); if((fp=fopen("mimazh.txt","rb"))==NULL){printf("未创建密码\n");}break;
}
fread(&s,sizeof(int),1,fp);
fclose(fp);
printf("请输入密码\n");
scanf("%d",&mi);
system("cls");
if(mi==s)
return 2;
else
{
printf("密码输入错误,请重试\n");
return 0;
}
}
void change(int w)//修改密码
{
FILE *fp;int s,d;
switch(w)
{
case 1:fp=fopen("mimaz.txt","wb"); if((fp=fopen("mimaz.txt","wb"))==NULL) printf("无法创建密码文件\n");break;
case 2:fp=fopen("mimazf.txt","wb"); if((fp=fopen("mimazf.txt","wb"))==NULL) printf("无法创建密码文件\n");break;
case 3:fp=fopen("mimazh.txt","wb"); if((fp=fopen("mimazh.txt","wb"))==NULL) printf("无法创建密码文件\n");break;
}
if(check(w)==2)
{
printf("请输入新密码\n");
scanf("%d",&s);system("cls");
printf("请输入确认新密码\n");
scanf("%d",&d);system("cls");
if(s==d)
{
fwrite(&s,sizeof(int),1,fp);
fclose(fp);
printf("密码修改成功\n");
}
}
}
int panduan(int a)//密码开关,返回:0关闭密吗1则开启
{
FILE *fp;int i;
switch(a)
{
case 1:fp=fopen("panduanz.txt","rb");if((fp=fopen("panduanz.txt","rb"))==NULL) fp=fopen("panduanz.txt","wb");break;
case 2:fp=fopen("panduanzf.txt","rb");if((fp=fopen("panduanzf.txt","rb"))==NULL) fp=fopen("panduanzf.txt","wb");break;
case 3:fp=fopen("panduanzh.txt","rb");if((fp=fopen("panduanzh.txt","rb"))==NULL) fp=fopen("panduanzh.txt","wb");break;
}fread(&i,sizeof(int),1,fp);
if(i==1)
return 1;
else return 0;
fclose(fp);
}
void xiugai(int a)//改变密码状态
{
FILE *fp;
int i;
printf("输入1开启密码,输入其他任意数关闭密码\n");
scanf("%d",&i);
switch(a)
{
case 1:fp=fopen("panduanz.txt","wb");break;
case 2:fp=fopen("panduanzf.txt","wb");break;
case 3:fp=fopen("panduanzh.txt","wb");break;
}
fwrite(&i,sizeof(int),1,fp);
if(i==1)
printf("密码启用成功\n");
else
printf("关闭密码成功\n");
fclose(fp);
}
//-----------------------------------------------------------------------------------输入输出
void scwork()//输入员工信息
{
scanf("%d %s %d %d %d %d",&person[i].num,person[i].name,&person[i].date1,
&person[i].date2,&person[i].date3,&person[i].date4);
}
void prwork()//输出员工信息
{
printf("%d:工号%d 名字%s %d号 %d号 %d号 %d号\n",i,person[i].num,person[i].name,
person[i].date1,person[i].date2,person[i].date3,person[i].date4);
}
void scroom()//输入房间信息
{
scanf("%d %s %c %d%d",&read[i].number,read[i].type,
&read[i].now,&read[i].date1,&read[i].date2);
}
void prroom()//输出房间信息
{
printf("%d:房号%d 类型%s 状态%c 入住日期%d号 退房日期%d号\n",i,read[i].number,
read[i].type,read[i].now,read[i].date1,read[i].date2);
}
void sccai()//输入菜谱信息
{scanf("%s %d %d",can[i].name,&can[i].price,&can[i].number);}
void prcai()//输出菜谱信息
{
printf("%d: %s %d元 %d\n",i,can[i].name,can[i].price,can[i].number);
}
void head()//总经理
{
system("cls");
printf("|------------------------------------------------------------------|\n");
printf("|* ************欢迎来到森森饭店管理系统************ *|\n\n");
printf("|* ************************************************ *|\n\n");
printf("|------------------------------------------------------------------|\n\n");
}
//---------------------------------------------------------------------------员工信息
void numbe()// 读取员工数
{
FILE *fx;
fx=fopen("number.tx","rb");
if((fx=fopen("number.txt","rb"))==NULL)
{
fx=fopen("number.txt","wb");
number=0;
printf("仍未创建资料,请输入资料\n");
}
else
fread(&number,sizeof(int),1,fx);
}
void readwork()// 读取员工信息
{
FILE *fp;
fp=fopen("staff.txt","rb");
if((fp=fopen("staff.txt","rb"))==0)
{
printf("文件打不开,或未创建\n");
}
else
{
numbe();
for(i=0;i<number;i++)
fread(&person[i],sizeof(struct wo),1,fp);
fclose(fp);
}
}
void savework()//保存员工信息
{
FILE *fp,*fn;
fp=fopen("staff.txt","wb");
for(i=0;i<number;i++)
fwrite(&person[i],sizeof(struct wo),1,fp);
fclose(fp);
fn=fopen("number.txt","wb");
fwrite(&number,sizeof(int),1,fn);
fclose(fn);
}
void arragework()//重置员工信息
{
printf("输入您想要安排的人员个数\n");
scanf("%d",&number);
printf("工号 姓名 每月休息日期1: 2: 3: 4: \n");
for(i=0;i<number;i++)
scwork();
savework();
}
void addwork()//增加员工信息
{
int a;
printf("增加插入个数:");
scanf("%d",&a);number=number+a;
printf("工号 姓名 每月休息日期1: 2: 3: 4:\n");
for(i=number-a;i<number;i++)
scwork();
savework();
printf("增加成功\n");
}
void searchname()//按照名字查询
{
char name[12];int r=0;
printf("请输入名字\n");
scanf("%s",name);
for(i=0;i<number;i++)
if(strcmp(person[i].name,name)==0)
{
r=1;
prwork();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchnum()//按照工号查询
{
int num;int r=0;
printf("请输入num\n");
scanf("%d",&num);
for(i=0;i<number;i++)
if(person[i].num==num)
{
r=1;
prwork();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchday()//按照休息日期查询
{
int num;int r=0;
printf("请输入日期\n");
scanf("%d",&num);
for(i=0;i<number;i++)
if(person[i].date1==num||person[i].date2==num||person[i].date3==num||person[i].date4==num)
{
r=1;
prwork();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchwork()//收索员工信息
{
do{
printf("请输入收索方式:\n 按名字:1 按工号:2 按休息日期:3 结束查询:4\n");
scanf("%d",&i);
switch(i)
{case 1:searchname();break;
case 2:searchnum();break;
case 3:searchday();break;
case 4:break;
default:printf("输入错误,请重新输入\n");break;
}
}while(i!=4);
}
void seeallwork()//查看员工休息日期
{
for(i=0;i<number;i++)
prwork();
}
void delework()//删除员工信息
{
int s;
printf("输入删除的序号\n");
scanf("%d",&i);
number=number-1;
prwork();
printf("确认删除?确认:1 取消:2");
scanf("%d",&s);
if(s==2)
system("pause");
for(i=i;i<number;i++)
person[i]=person[i+1];
savework();
printf("删除成功\n");
}
void modifywork()//更改员工信息
{
printf("输入修改的序号:");
scanf("%d",&i);printf("更改前:");
prwork();
printf("请更改:");
scwork();
savework();
printf("更改成功\n");
}
//-----------------------------------------------------------------------------------菜菜
void numbe2()//统计存菜信息数
{
FILE *fx;
fx=fopen("number2.tx","rb");
if((fx=fopen("number2.txt","rb"))==NULL)
{
fx=fopen("number2.txt","wb");
number=0;
printf("仍未创建资料,请输入资料\n");
}
else fread(&number2,sizeof(int),1,fx);
}
void readcai()//读取菜的信息
{
FILE *fp;
fp=fopen("cai.txt","rb");
if((fp=fopen("cai.txt","rb"))==NULL)
printf("文件打不开,或未创建\n");
else
{
numbe2();
for(i=0;i<number2;i++)
fread(&can[i],sizeof(struct cai),1,fp);
fclose(fp);
}
}
void savecai()//保存菜的信息
{
FILE *fp,*fn;
fp=fopen("cai.txt","wb");
for(i=0;i<number2;i++)
fwrite(&can[i],sizeof(struct cai),1,fp);
fclose(fp);
fn=fopen("number2.txt","wb");
fwrite(&number2,sizeof(int),1,fn);
fclose(fn);
}
void addcai()//增加菜的信息
{
int a;readcai();
printf("输入增加个数\n");
scanf("%d",&a);number2=number2+a;
printf("菜名 单价 数量\n");
for(i=number2-a;i<number2;i++)
sccai();
savecai();
printf("增加成功\n");
}
void searchnam()//按照菜名查询
{
char name[12];int r=0;
printf("请输入名字\n");
scanf("%s",name);
for(i=0;i<number;i++)
if(strcmp(can[i].name,name)==0)
{
r=1;
prcai();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchnum2()//按照菜的数量
{
int num;int r=0;
printf("请输入num\n");
scanf("%d",&num);
for(i=0;i<number2;i++)
if(can[i].number==num)
{
r=1;
prcai();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchprice()//按照价格查询
{
int num;int r=0;
printf("请输入价格\n");
scanf("%d",&num);
for(i=0;i<number;i++)
if(can[i].price==num)
{
r=1;
prcai();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchcai()//收索菜的信息
{
do
{
printf("请输入收索方式:\n 按菜名:1 按数量号:2 按单价:3 不做任何操作:4\n");
scanf("%d",&i);
switch(i)
{
case 1:searchnam();break;
case 2:searchnum2();break;
case 3:searchprice();break;
case 4:break;
default:printf("输入错误,请重新输入\n");break;
}
}while(i!=4);
}
void seeallcai()//查看所有菜的信息
{
for(i=0;i<number2;i++)
prcai();
}
void delecai()//删除菜的信息
{
printf("输入删除的序号\n");
int s;
scanf("%d",&i);
prcai();
printf("确认删除?确认:1 取消:2");
scanf("%d",&s);
if(s==2)system("pause");
number2=number2-1;
for(i=i;i<number2;i++)
can[i]=can[i+1];
savecai();
printf("删除成功\n");
}
void modifycai()//更改菜的信息
{
printf("输入修改的位置:");
scanf("%d",&i);
printf("更改前:");prcai();
printf("请更改:");sccai();
savecai();printf("更改成功\n");
}
//-----------------------------------------------------------------------------------房间信息
void numbe1()
{
FILE *fx;
fx=fopen("number1.tx","rb");
if((fx=fopen("number1.txt","rb"))==NULL)
{
fx=fopen("number1.txt","wb");
number1=0;
printf("仍未创建资料,请输入资料\n");
}
else fread(&number1,sizeof(int),1,fx);
}
void readroom()
{
FILE *fp;
fp=fopen("room.txt","rb");
if((fp=fopen("room.txt","rb"))==NULL)
printf("文件打不开,或未创建\n");
else
{
numbe1();
for(i=0;i<number1;i++)
fread(&read[i],sizeof(struct room),1,fp);
fclose(fp);
}
}
void saveroom()//安排员工休息日期
{
FILE *fp,*fn;
fp=fopen("room.txt","wb");
for(i=0;i<number1;i++)
fwrite(&read[i],sizeof(struct room),1,fp);
fclose(fp);
if(number1>100)
printf("超过资料存储界限\n");
else
{
fn=fopen("number1.txt","wb");
fwrite(&number1,sizeof(int),1,fn);
fclose(fn);
}
}
void arrageroom()//重置房间信息
{
int s;
printf("输入您想要重置的房间个数(温馨提示您现在的操作会删掉原来的数据:输入0表示取消操作)\n");
scanf("%d",&s);
if(s==0)
printf("已取消该操作\n");
else
{
number1=s;
printf("房号 类型 房间状态(e表示有人住f表示空) 入住日期 退房日期\n");
for(i=0;i<number1;i++)
scroom();
saveroom();printf("重置成功\n");
}
}
void addroom()//重置房间信息
{
int a,s;readroom();
printf("输入插入个数\n");scanf("%d",&a);
printf("输入插入位置\n");scanf("%d",&s);
printf("房号 类型 房间状态(e表示有人住f表示空) 入住日期 退房日期\n");
if(number1+a>100)
printf("超过储存界限\n");
else
{
number1=number1+a;
for(i=number-1;i>s-1;i--)
read[i]=read[i-a];
for(i=s;i<s+a;i++)
scroom();
saveroom();
}
}
void searchlei()//按照房间类型类型查询
{
char name[12];int r=0;
printf("请输入类型\n");
scanf("%s",name);
for(i=0;i<number1;i++)
if(strcmp(read[i].type,name)==0)
{
r=1;
prroom();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchnum1()//按照房间号
{
int num1;int r=0;
printf("请输入num\n");
scanf("%d",&num1);
for(i=0;i<number1;i++)
if(read[i].number==num1)
{
r=1;
prroom();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchday1()//按照日期查询
{
int num1;int r=0;
printf("请输入日期\n");
scanf("%d",&num1);
for(i=0;i<number1;i++)
if(read[i].date1==num1||read[i].date2==num1)
{
r=1;
prroom();
}
if(r==0)
printf("没有符合的资料\n");
}
void searchroom()//房间信息查询
{
do
{
printf("请输入收索方式:\n 按类型:1 按房号:2 按日期:3 结束收索:4\n");
scanf("%d",&i);
switch(i)
{
case 1:searchlei();break;
case 2:searchnum1();break;
case 3:searchday1();break;
case 4:break;
default:printf("输入错误,请重新输入\n");break;
}
}while(i!=4);
}
void seeallroom()//查看所有房间信息
{
for(i=0;i<number1;i++)
prroom();
}
void deleroom()//删除房间信息
{
printf("输入删除的序号\n");
int s;
scanf("%d",&i);
prroom();
printf("确认删除?确认:1 取消:2");
scanf("%d",&s);
if(s==2)
system("pause");
number1=number1-1;
for(i=i;i<number1;i++)
read[i]=read[i+1];
saveroom();
printf("删除成功\n");
}
void modifyroom()//更改房间信息
{
printf("输入更改的序号\n");
scanf("%d",&i);
printf("更改前:");
prroom();
printf("请更改:");
scroom();
saveroom();printf("更改成功\n");
}
//----------------------------------------------------二级菜单-------------------------------------------------
void food(int a)//--------------------------餐饮部1
{
int select,j=0;
readwork();
readcai();
printf("| ------------------------------------ |\n");
printf("|** * 欢迎来到餐饮部 * **|\n\n");
printf("| ------------------------------------ |\n");
if(a==0)
turn1:
{j=1;
do{
printf("请选择功能\n");
printf(" 退出:0 查看所有菜1\n");
printf(" 改菜:2 搜菜:3\n");
printf(" 添加菜4 删除菜5\n");
printf(" 查看所有员工:6 查询个别员工7\n");
if( a==1)
{
printf(" 修改密码:8 启用密码:9\n");
printf(" 添加员工信息10 更改员工信息11\n");
}
scanf("%d",&select);
if(select>7&&a==0)
select=32;
switch(select)
{
case 9:xiugai(2);break;
case 8:change(2);break;
case 6:seeallwork();break;
case 2:modifycai();break;
case 3:searchcai();break;
case 4:addcai();break;
case 5:delecai();break;
case 1:seeallcai();break;
case 11:modifywork();break;
case 10:addwork();break;
case 7:searchwork();break;
case 0:printf("退出餐饮部\n");break;
default:printf("输入错误,请重新输入^U^\n");
}
}while(select!=0);
}
else if(j==0)
{
if(panduan(2)==0)
goto turn1;
else
if(check(2)==2)
goto turn1;
}
}
void hall(int a)//--------------------------前厅2
{
int j=0;
readroom();readwork();
if(a==0)
{
int select;
do
{
retryh: printf("| ---------------------------------- |\n");
printf("|** * 欢迎来到前厅 * **|\n");
printf("| ---------------------------------- |\n");j=1;
printf("请选择相应的功能:\n");
printf(" 退出:0 查看所有房间信息:1\n 房间查询:2 更改房间信息:3\n");
printf(" 查询员工信息:4 查看所有员工信息:5\n");
if(a==1)
{
printf(" 增加房间:6 删除房间:7\n");
printf(" 启用密码:8 修改密码:9\n");
printf(" 增加员工信息:10 更改员工信息:11\n");
printf(" 重置房间信息:12 \n");}
scanf("%d",&select);
if(select>4&&a==0)
select=32;
switch(select)
{
case 8:xiugai(3);break;
case 9:change(3);break;
case 5:seeallwork();break;
case 3:modifyroom();break;
case 7:deleroom();break;
case 2:searchroom();break;
case 6:addroom();break;
case 4:searchwork();break;
case 10:addwork();break;
case 11:modifywork();break;
case 12:arrageroom();break;
case 1:seeallroom();break;
case 0:printf("退出前厅\n");break;
default:printf("*_*输入错误,请重新输入^U^\n");
}
}while(select!=0);
}else if(j==0)
{
if(panduan(3)==0)
goto retryh;
else
if(check(3)==2)
goto retryh;
}
}
//----------------------------------------------------主级菜单--------------------------------------
void menu()//总经理菜单
{
int select;
do
{
readwork();readcai();readroom();
printf("| ---------------------------------- |\n");
printf("|** * 欢迎总经理! * **|\n");
printf("| ---------------------------------- |\n");
printf("请选择功能\n");
printf(" 退出:0 查看所有员工:1\n");
printf(" 查询员工信息2 添加员工:3\n");
printf(" 删除员工信息4 更改员工信息:5\n");
printf(" 查看所有菜6 查询菜7\n");
printf(" 查看房间信息8 收索房间9\n 重置员工安排:10");
printf(" 启用密码:11 \n 修改密码:12\n");
scanf("%d",&select);system("cls");
switch(select)
{
case 11:xiugai(1);break;
case 12:change(1);break;
case 10:arragework();break;
case 1:seeallwork();break;
case 3:addwork();break;
case 2:searchwork();break;
case 4:delework();break;
case 7:searchcai();break;
case 6:seeallcai();break;
case 8:seeallroom();break;
case 9:searchroom();break;
case 5:modifywork();break;
case 0:break;
default:printf("输入错误,请重新输入^U^\n");
}
}while(select!=0);
}
void zjl()//总经理登陆
{
if(panduan(1)==0)
menu();
else if(check(1)==2)
menu();
}
void department(int s)//经理/员工登陆界面
{
int a;
system("cls");
printf("请选择部门:\n");
do
{
printf(" |-----------------------|\n");
printf(" |退出:0 餐饮部:1|\n |前厅:2 |\n");
printf(" |-----------------------|\n");
printf(" 请输入序号:\n");
scanf("%d",&a);
switch(a)
{
case 1:food(s);break;
case 2:hall(s);break;
case 0:break;
default:printf("*_*输入错误,请重新输入^U^\n");
}
}while(a!=0);
}
void main()//主函数
{
int select;
start: head();
printf("请选择登陆身份:\n");
printf(" ----------------------\n");
printf(" |总经理请输入:1 |\n");
printf(" |经理请输入:2 |\n");
printf(" |普通员工请输入:3 |\n");
printf(" |退出:0 |\n");
printf(" ----------------------\n");
scanf("%d",&select);
switch(select)
{
case 1:zjl();goto start;
case 2:department(1);goto start;
case 3:department(0);goto start;
有错误。。。帮忙看一下
--------------------Configuration: adsf - Win32 Debug--------------------
Compiling...
adsf.c
c:\documents and settings\administrator\adsf.c(410) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\adsf.c(414) : error C2065: 's' : undeclared identifier
c:\documents and settings\administrator\adsf.c(573) : error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\administrator\adsf.c(785) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
adsf.obj - 1 error(s), 0 warning(s)
帮忙改下吧大神们