📄 main.cpp
字号:
//#include"stdio.h"
//#include<iostream>
//using namespace std;
#include"book_struct.h"
#include"acridine.h"
#include"string.h"
#include"conio.h"
#include"iostream.h"
void judge(char ch,double &n);
int judge_number(int &i,char string[]);
int load_book_massage(bomas &B);
void administrator_switch(bomas &B,char n[],member &head);
void acridine_switch(bomas B,acridine *p0,char n[]);
void read_to_link(member &yonghu);//形参为user类型的结点,user为结构体指针类型
void main_menu();
void administrator_menu();
void acridine_menu();
void create_bookmas(bomas &B);
void about();
void code_protect(char a[]);//实现密码变星
int member_enter(user *head,member &p);//会员登录函数
void adduser();//增加会员函数
void free_book_link(bomas &B);//清空图书链表
void free_user_link(member &head);//清空会员链表
int writeintobook(member &yonghu);//把从实参传过来的yonghu链表(yonghu为头结点)的信息写进文件
main()
{
int i=0;
int flag=-1;
char n[2]={-1};
char ch;
char administrator_code[]="000000";//j将密码初始化
char code[10];
acridine *p0=NULL,*head=NULL;
bomas B;
while(n[0]!='0')//主菜单功能
{
main_menu();//主菜单显示函数
n[0]=-1;
flag=judge_number(i,n);
if(i>1||!flag)
{
cout<<" 输入不正确"<<endl;
}
else
{
switch(n[0])
{
case'1'://管理员登录
printf(" 请输入密码(六位):");
code_protect(code);
cout<<endl;
system("cls");
if(strcmp(administrator_code,code)==0)//如果输入的密码正确,则进行以下操作
{
load_book_massage(B);//信息读取
read_to_link(head);
while(n[0]!='0')
{
administrator_menu();//管理员菜单
administrator_switch(B,n,head);//管理员操作
}
n[0]=-1;//对n[0]重新赋值,避免内循环n[0]的值对外循环造成影响
free_book_link(B);
free_user_link(head);
}
else
{
cout<<" 密码错误"<<endl<<endl<<endl;
}
break;
case'2'://会员登录
head=NULL;
read_to_link(head);
flag=-1;
flag=member_enter(head,p0);//会员登录
if(!flag)//如果找不到该登录失败,退出
{
free_user_link(head);
break;
}
load_book_massage(B);
system("cls");
n[0]=-1;
while(n[0]!='0')
{
acridine_menu();//会员菜单
acridine_switch(B,p0,n);//会员操作
}
n[0]=-1;
writeintobook(head);
free_book_link(B);
free_user_link(head);
break;
case'3'://会员注册
system("cls");
adduser();
cout<<endl<<" 请按回车键返回主菜单"<<endl;
printf(" ");
while((ch=getchar())!='\n');//按回车键返回主菜单
{}
system("cls");
break;
case'4'://关于
system("cls");
about();
cout<<endl<<" 请按回车键返回主菜单"<<endl;
printf(" ");
while((ch=getchar())!='\n');//按回车键返回主菜单
{}
system("cls");
break;
case'0'://退出
// system("cls");
break;
default:
cout<<" 输入不正确!"<<endl;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -