图书管理系统程序代码

图书管理系统程序代码

#include

#include

#include

#include

#include

#define MAXNUM 10

#define MAXNUM 10

#define NUMBER 20/*最大物品数量*/

#define TRUE 1

#define FALSE 0

typedef struct book

{

long int starting;// 借书日期

long int ending;// 应还日期

char bookinform[120];// 这里面存储书籍的描述信息

long int callnum;// 索书号

char bookname[30];

char writer[20];

int totalstorage, nowstorage;// 书本的馆藏量,现有量

}book;

/* 本结构体用于创建链表的二叉树 */

typedef struct volume

{

book books;

struct volume *lchild;

struct volume *rchild;

}volume,*Btvolume;

typedef struct libcard

{

char userID[12];

char password[12];// 密码

char clientname[20];// 用户的名字

char usermessage[150];// 用户信息

book borrow[10];// 每本借书证限借书十本

struct libcard *next;

}libcard;

libcard *clients,*current_client=NULL;

/*

* 函数声明

*/

void createBST(Btvolume *bst);

void insertBST(Btvolume *bst,book *key);

Btvolume searchBST(Btvolume bst,long int key);

void GetPassword(char *str,int n);

int registerer();

int login();// 登录

void clientsev(volume **Btroot);// 客户(学生)

int check_client(libcard **client);

void in_stor(volume **root);// 入库

void backbook(Btvolume *root,long int callnum);// 还书

int lend(Btvolume *root,long int callnum);// 借书,有学生发出请求

struct Record/*本结构体用于保存每一次结果*/

{

int totalWeight;/*本次结果的总价值*/

int goods[NUMBER];/*本次结果对应的下标*/

struct Record *next;

};

struct Record *headLink;

struct Record result;

int stack[NUMBER];

int top;

int weight[NUMBER];/*保存物品重量的数组*/

int value[NUMBER];/*保存对应(下标相同)物品的价值*/

int knapproblen(int n,int maxweight,int weight[]);

void CreateHeadLink(void);

struct Record *MallocNode(void);

void InsertOneNode(struct Record *t);

void GetResult(void);

void ShowResult(void);

main(){

int a;

printf("---------------- 选择访问程序 ---------------- \n");

printf("---------------- 1.背包问题 ---------------- \n");

printf("---------------- 2.图书系统 ---------------- \n");

printf("---------------- 0.退出系统 ---------------- \n");

printf("---------------------------------------------- \n");

scanf("%d",&a);

if(a==1)

beibao();

else if(a==2)

tushuguanli();

}

/*

*建立图书库第一本书

*/

void createBST(Btvolume *bst)

{

book *key;

*bst=NULL;

key=(book *)malloc(sizeof(book));

key->starting=0;

key->ending=0;

printf("输入索书号:");

scanf("%ld",&(key->callnum));

if(key->callnum == 0){

free(key);

}

printf("输入入库量:");

scanf("%d",&(key->totalstorage));

key->nowstorage=key->totalstorage;

printf("输入书本名:");

scanf("%s",&(key->bookname));

printf("输入著作者:");

scanf("%s",&(key->writer));

printf("输入书描述:");

scanf("%s",&(key->bookinform));

if(key!=NULL)

insertBST(bst,key);

}

/*

* 二叉排序树的插入模块,采用递归算法实现 */

void insertBST(Btvolume *bst,book *key)

{

Btvolume s;

if(*bst==NULL)// 递归结束条件

{

s=(Btvolume)malloc(sizeof(volume));

s->books.callnum = key->callnum;

s->books.nowstorage = key->nowstorage;

s->books.totalstorage = key->totalstorage;

s->books.starting = key->starting;

s->books.ending = key->ending;

strcpy(&(s->books.bookinform),&(key->bookinform));

strcpy(&(s->books.bookname),&(key->bookname));

strcpy(&(s->books.writer),&(key->writer));

s->lchild=NULL;

s->rchild=NULL;

*bst=s;

}

else if(key->callnum books.callnum)

{

insertBST(&((*bst)->lchild),key);

}

else if(key->callnum > (*bst)->books.callnum)

{

insertBST(&((*bst)->rchild),key);

}

else

{

(*bst)->books.nowstorage+=key->nowstorage;

(*bst)->books.totalstorage+=key->totalstorage;

}

}

/*

* 二叉排序树的查找算法 按索书号为关键字进行二分查找

Btvolume searchBST(Btvolume bst,long int key)

{

if(bst==NULL)

return NULL; */

if(bst->books.callnum == key)

return bst;

if(bst->books.callnum

return searchBST(bst->rchild,key);

return searchBST(bst->lchild,key);

}

/*

* 入库函数,用于增加书本库存 函数无返回值 实现:1、排序二叉树的建立 2、排序二叉树的查找 3、排序二叉树的插入 4、排序二叉树的删除

* 说明:在这里并没有对物理层进行操作

*/

void in_stor(volume **root)

{

Btvolume p,q;

book *key;

/* 输入数据 */

key=(book*)malloc(sizeof(book));

printf("输入索书号:");

scanf("%ld",&(key->callnum));

printf("输入入库量:");

scanf("%d",&(key->totalstorage));

key->nowstorage=key->totalstorage;

printf("输入书本名:");

scanf("%s",&(key->bookname));

printf("输入著作者:");

scanf("%s",&(key->writer));

printf("输入书描述:");

scanf("%s",&(key->bookinform));

key->starting = 0;

key->ending = 0;

insertBST(root,key);

}

/*

* 借书模块,由学生发出请求 返回借书是否成功 如果当前的可借阅量大于0且学生当前借书量未超过限制 则借书成功 否则失败 */

int lend(Btvolume *root,long int callnum)

{

int success=0;// 作为返回值,用于标记借阅是否成功

int i=0;

time_t t;

Btvolume temp;

while(current_client->borrow[i].callnum>0)

i++;

if(i>=10)

printf("对不起,您借的书过多,请先还书!\n");

else

{

temp=searchBST(*root,callnum);

if(temp==NULL)

printf("对不起,本馆没有收藏此书!\n");

else if(temp->books.nowstorage > 0)

{

time(&t);

temp->books.nowstorage -= 1;

current_client->borrow[i].callnum = callnum;

current_client->borrow[i].starting = t;// 获取当前系统时间

current_client->borrow[i].ending = current_client->borrow[i].starting+2592000;

current_client->borrow[i].totalstorage = temp->books.totalstorage; current_client->borrow[i].nowstorage = temp->books.nowstorage;

strcpy(current_client->borrow[i].bookinform , temp->books.bookinform); strcpy(current_client->borrow[i].bookname , temp->books.bookname); strcpy(current_client->borrow[i].writer , temp->books.writer);

success=1;

printf("您已经成功借书,欢迎下次光临!\n");

}

else

printf("对不起,该书已被借完!\n");

}

return success;

}

/*

* 还书模块,有学生发出请求 每次只能还一本书 即便是两本同样的书也需还两次! 无返回值 还书后相应库存量增加,同时学生的当前借阅量减少

* 如果超期,返回超期天数

*/

void backbook(Btvolume *root,long int callnum)

{

Btvolume temp;

time_t t;

int i=0;

double overtime;

while(i

{

if(current_client->borrow[i].callnum==callnum)

break;

i++;

}

if(i>=10)

{

printf("对不起,您并未借过此书!\n");

return;

}

temp=searchBST(*(root),callnum);

if(temp==NULL)

{

printf("您好,本馆并未藏有此书, 因此你所还的书不是本馆!\n");

return;

}

if(temp->books.nowstorage >= temp->books.totalstorage)

{

printf("对不起,本馆未借出此书!\n");

return;

}

time(&t);

if( t > current_client->borrow[i].ending)

{

overtime=((t- current_client->borrow[i].ending)/43200)+1;

printf("对不起,您所借的书已经超期 %0.0f 天\n",overtime);

}

/* 还书后所做的处理 */

temp->books.nowstorage++;

current_client->borrow[i].bookinform[0]='\0';

current_client->borrow[i].bookname[0]='\0';

current_client->borrow[i].callnum=0;

current_client->borrow[i].ending= 2004967296;//

current_client->borrow[i].starting=0;

current_client->borrow[i].nowstorage=0;

current_client->borrow[i].totalstorage=0;

current_client->borrow[i].writer[0]='\0';

printf("书已成功归还, 欢迎下次光临!\n");

}

/*注册模块*/

int registerer()

{

libcard *client,*client_temp=NULL;

char temp[13];

int type,success=0;

int i;

while(1){

while(1){

但允许相同密码

无穷大

client=(libcard*)malloc(sizeof(libcard));// 这里很重要 client->next=NULL; printf("------------按要求填写有关注册信息--------------\n"); printf("用户ID :"); scanf("%s",&client->userID); /* * 检测是否为重复注册 */ client_temp=clients; while(client_temp!=NULL) { if(!strcmp(client->userID , client_temp->userID))// 不允许相同ID break; client_temp=client_temp->next; } if(client_temp == NULL)// 没有相同的ID { /* * 注册成功后应对信息进行初始化 */ for(i=0;iborrow[i].bookinform[0] = '\0'; client->borrow[i].bookname[0] = '\0'; client->borrow[i].writer[0] = '\0'; client->borrow[i].callnum = 0; client->borrow[i].starting = 0; client->borrow[i].ending = 315360000;// 将归还日期初始为 client->borrow[i].nowstorage = 0; client->borrow[i].totalstorage = 0; } client->next=clients;

clients=client;

}

else

{

printf("对不起,该ID 已被占用, 注册失败!\n");

break;

}

while(1)

{

printf("密码:");

GetPassword(&client->password,12);

// scanf("%s",&client->password);

printf("确认密码:");

GetPassword(&temp,12);

// scanf("%s",&temp);

if(!strcmp(client->password,temp))// 检测密码是否有误 break;

printf("您的密码输入有误,请从新输入\n");

}

printf("请输入用户名字:");

scanf("%s",&client->clientname);

printf("请输入用户描述:");

scanf("%s",&client->usermessage);

break;

}

printf("是否继续注册?(1、继续)(0、退出)");

scanf("%d",&type);

if(!type)

break;

}

return success;

}

/*核对用户信息*/

int check_client(libcard **client)

{

int success=0;

libcard *temp=clients;

while(temp!=NULL ) //循环验证借书证

{

if(!strcmp((*client)->userID , temp->userID)&&!strcmp((*client)->password , temp->password)) //如果有其一不对应,则跳入下面一个用户验证 {

} free(*client); *client=temp; success=1; break; } temp=temp->next; } return success; /* * 客户 */ void clientsev(volume **Btroot) { int a,b; volume *temp; libcard *p=NULL;// 用作临时指针 if(current_client==NULL) { printf("您还未登录,请登录!\n"); login(); return;// 不管是否成功登陆都将返回原处 } while(1) { system("cls");// //////////清屏 printf("----------------- 图书管理系统 -----------------\n"); printf("-------------------客户用户---------------------\n"); printf(" --------------- 1、图书借阅--------------------\n"); printf(" --------------- 2、图书归还--------------------\n"); printf(" --------------- 0、退出------------------------\n"); scanf("%d",&a); switch(a) { case 1: printf("输入索书号:\n"); scanf("%d",&b); lend(Btroot,b);

} } break; case 2: printf("输入索书号:\n"); scanf("%d",&b); backbook(Btroot,b); break; default:return; } system("pause");// ////////////////////////// /* * 登录模块 返回登录的用户类型 用户必须先登录才能对图书进行操作 */ int login() { libcard *temp_client=NULL; int type,temp; printf("----------------- 图书管理系统-----------------\n"); printf("------------------客 户 登 录------------------\n"); printf("确认按1:"); scanf("%d",&type); while(1) { if(current_client!=NULL) { printf("对不起,登录人数已满,您目前还不能登陆!\n"); break; } temp_client = (libcard *)malloc(sizeof(libcard)); printf("请输入借阅证号:"); scanf("%s",&temp_client->userID); printf("请输入密码:"); GetPassword(&temp_client->password,12); // scanf("%s",&temp_client->password); if(check_client(&temp_client))// 调用函数检查 { current_client=temp_client; return type; } else {

printf("对不起,密码错误!\n");

free(temp_client);

current_client = NULL;

break;

}

}

printf("(0、退出)\n");

scanf("%d",&temp);

if(!temp)return 0;

}

/*

从键盘获取字符密码, 显示为*,设定最大字符数为n

*/

void GetPassword(char *str,int n)

{

int i=0;

char c;

while((c=getch())!=13&&i

{

if(c!=8)

{

putch('*');//回显*

str[i++]=c;

}

else

i--;

}

putch('\n');

str[i]='\0';

}

int tushuguanli()

{

int a=0,b,i;

int cases=0,goornot;

book booker;

volume root,*Btroot;

printf("---------------欢迎访问图书管理系统---------------\n"); printf("---------------初次用系统先建立书库---------------\n"); printf("---------------按照提示输入有关信息----------------\n");

/*

* 读取所有管理员和客户

*/

createBST(&Btroot);// 在系统启动时调出记录

while(1){

printf("---------------提示-----------------\n");

printf("----------按1继续添加图书-----------\n");

printf("----------其他进入系统界面----------\n");

scanf("%d",&i);

if(i==1)

in_stor(Btroot);

else

break;}

while(1)

{

system("cls");// //////////清屏

printf("----------------- 图书管理系统 -----------------\n"); printf("----------------- 选择您的操作 -----------------\n"); printf("------------------1、注 册-----------------------\n"); printf("------------------2、登 录-----------------------\n"); printf("------------------3.其他进入系统界面--------------\n"); cases=0;//

scanf("%d",&b);

switch(b)

{

case 1:

registerer();

break;

case 2:

cases=login();

default:break;

}

/*

* 选择登录的用户 本系统必须先登录才能操作 */

printf("-------------------图书管理系统 ------------------\n"); printf("-------------------选择您的操作 ------------------\n"); printf(" -----------------1、用户注册----------------------\n"); printf(" -----------------2、用户登录----------------------\n"); printf(" -----------------3、图书入库----------------------\n"); printf(" -----------------4、进入用户界面 -----------------\n"); scanf("%d:",&b);

switch(b)

{

case 1:

registerer();

break;

case 3:

in_stor(Btroot);

break;

case 2:

login();

break;

case 4:

clientsev(&Btroot);

default:break;

}

system("cls");// //////////清屏

printf("是否继续(1、继续)(0、退出)"); scanf("%d",&goornot);

if(!goornot)

break;

}

return 0;

}

图书管理系统程序代码

#include

#include

#include

#include

#include

#define MAXNUM 10

#define MAXNUM 10

#define NUMBER 20/*最大物品数量*/

#define TRUE 1

#define FALSE 0

typedef struct book

{

long int starting;// 借书日期

long int ending;// 应还日期

char bookinform[120];// 这里面存储书籍的描述信息

long int callnum;// 索书号

char bookname[30];

char writer[20];

int totalstorage, nowstorage;// 书本的馆藏量,现有量

}book;

/* 本结构体用于创建链表的二叉树 */

typedef struct volume

{

book books;

struct volume *lchild;

struct volume *rchild;

}volume,*Btvolume;

typedef struct libcard

{

char userID[12];

char password[12];// 密码

char clientname[20];// 用户的名字

char usermessage[150];// 用户信息

book borrow[10];// 每本借书证限借书十本

struct libcard *next;

}libcard;

libcard *clients,*current_client=NULL;

/*

* 函数声明

*/

void createBST(Btvolume *bst);

void insertBST(Btvolume *bst,book *key);

Btvolume searchBST(Btvolume bst,long int key);

void GetPassword(char *str,int n);

int registerer();

int login();// 登录

void clientsev(volume **Btroot);// 客户(学生)

int check_client(libcard **client);

void in_stor(volume **root);// 入库

void backbook(Btvolume *root,long int callnum);// 还书

int lend(Btvolume *root,long int callnum);// 借书,有学生发出请求

struct Record/*本结构体用于保存每一次结果*/

{

int totalWeight;/*本次结果的总价值*/

int goods[NUMBER];/*本次结果对应的下标*/

struct Record *next;

};

struct Record *headLink;

struct Record result;

int stack[NUMBER];

int top;

int weight[NUMBER];/*保存物品重量的数组*/

int value[NUMBER];/*保存对应(下标相同)物品的价值*/

int knapproblen(int n,int maxweight,int weight[]);

void CreateHeadLink(void);

struct Record *MallocNode(void);

void InsertOneNode(struct Record *t);

void GetResult(void);

void ShowResult(void);

main(){

int a;

printf("---------------- 选择访问程序 ---------------- \n");

printf("---------------- 1.背包问题 ---------------- \n");

printf("---------------- 2.图书系统 ---------------- \n");

printf("---------------- 0.退出系统 ---------------- \n");

printf("---------------------------------------------- \n");

scanf("%d",&a);

if(a==1)

beibao();

else if(a==2)

tushuguanli();

}

/*

*建立图书库第一本书

*/

void createBST(Btvolume *bst)

{

book *key;

*bst=NULL;

key=(book *)malloc(sizeof(book));

key->starting=0;

key->ending=0;

printf("输入索书号:");

scanf("%ld",&(key->callnum));

if(key->callnum == 0){

free(key);

}

printf("输入入库量:");

scanf("%d",&(key->totalstorage));

key->nowstorage=key->totalstorage;

printf("输入书本名:");

scanf("%s",&(key->bookname));

printf("输入著作者:");

scanf("%s",&(key->writer));

printf("输入书描述:");

scanf("%s",&(key->bookinform));

if(key!=NULL)

insertBST(bst,key);

}

/*

* 二叉排序树的插入模块,采用递归算法实现 */

void insertBST(Btvolume *bst,book *key)

{

Btvolume s;

if(*bst==NULL)// 递归结束条件

{

s=(Btvolume)malloc(sizeof(volume));

s->books.callnum = key->callnum;

s->books.nowstorage = key->nowstorage;

s->books.totalstorage = key->totalstorage;

s->books.starting = key->starting;

s->books.ending = key->ending;

strcpy(&(s->books.bookinform),&(key->bookinform));

strcpy(&(s->books.bookname),&(key->bookname));

strcpy(&(s->books.writer),&(key->writer));

s->lchild=NULL;

s->rchild=NULL;

*bst=s;

}

else if(key->callnum books.callnum)

{

insertBST(&((*bst)->lchild),key);

}

else if(key->callnum > (*bst)->books.callnum)

{

insertBST(&((*bst)->rchild),key);

}

else

{

(*bst)->books.nowstorage+=key->nowstorage;

(*bst)->books.totalstorage+=key->totalstorage;

}

}

/*

* 二叉排序树的查找算法 按索书号为关键字进行二分查找

Btvolume searchBST(Btvolume bst,long int key)

{

if(bst==NULL)

return NULL; */

if(bst->books.callnum == key)

return bst;

if(bst->books.callnum

return searchBST(bst->rchild,key);

return searchBST(bst->lchild,key);

}

/*

* 入库函数,用于增加书本库存 函数无返回值 实现:1、排序二叉树的建立 2、排序二叉树的查找 3、排序二叉树的插入 4、排序二叉树的删除

* 说明:在这里并没有对物理层进行操作

*/

void in_stor(volume **root)

{

Btvolume p,q;

book *key;

/* 输入数据 */

key=(book*)malloc(sizeof(book));

printf("输入索书号:");

scanf("%ld",&(key->callnum));

printf("输入入库量:");

scanf("%d",&(key->totalstorage));

key->nowstorage=key->totalstorage;

printf("输入书本名:");

scanf("%s",&(key->bookname));

printf("输入著作者:");

scanf("%s",&(key->writer));

printf("输入书描述:");

scanf("%s",&(key->bookinform));

key->starting = 0;

key->ending = 0;

insertBST(root,key);

}

/*

* 借书模块,由学生发出请求 返回借书是否成功 如果当前的可借阅量大于0且学生当前借书量未超过限制 则借书成功 否则失败 */

int lend(Btvolume *root,long int callnum)

{

int success=0;// 作为返回值,用于标记借阅是否成功

int i=0;

time_t t;

Btvolume temp;

while(current_client->borrow[i].callnum>0)

i++;

if(i>=10)

printf("对不起,您借的书过多,请先还书!\n");

else

{

temp=searchBST(*root,callnum);

if(temp==NULL)

printf("对不起,本馆没有收藏此书!\n");

else if(temp->books.nowstorage > 0)

{

time(&t);

temp->books.nowstorage -= 1;

current_client->borrow[i].callnum = callnum;

current_client->borrow[i].starting = t;// 获取当前系统时间

current_client->borrow[i].ending = current_client->borrow[i].starting+2592000;

current_client->borrow[i].totalstorage = temp->books.totalstorage; current_client->borrow[i].nowstorage = temp->books.nowstorage;

strcpy(current_client->borrow[i].bookinform , temp->books.bookinform); strcpy(current_client->borrow[i].bookname , temp->books.bookname); strcpy(current_client->borrow[i].writer , temp->books.writer);

success=1;

printf("您已经成功借书,欢迎下次光临!\n");

}

else

printf("对不起,该书已被借完!\n");

}

return success;

}

/*

* 还书模块,有学生发出请求 每次只能还一本书 即便是两本同样的书也需还两次! 无返回值 还书后相应库存量增加,同时学生的当前借阅量减少

* 如果超期,返回超期天数

*/

void backbook(Btvolume *root,long int callnum)

{

Btvolume temp;

time_t t;

int i=0;

double overtime;

while(i

{

if(current_client->borrow[i].callnum==callnum)

break;

i++;

}

if(i>=10)

{

printf("对不起,您并未借过此书!\n");

return;

}

temp=searchBST(*(root),callnum);

if(temp==NULL)

{

printf("您好,本馆并未藏有此书, 因此你所还的书不是本馆!\n");

return;

}

if(temp->books.nowstorage >= temp->books.totalstorage)

{

printf("对不起,本馆未借出此书!\n");

return;

}

time(&t);

if( t > current_client->borrow[i].ending)

{

overtime=((t- current_client->borrow[i].ending)/43200)+1;

printf("对不起,您所借的书已经超期 %0.0f 天\n",overtime);

}

/* 还书后所做的处理 */

temp->books.nowstorage++;

current_client->borrow[i].bookinform[0]='\0';

current_client->borrow[i].bookname[0]='\0';

current_client->borrow[i].callnum=0;

current_client->borrow[i].ending= 2004967296;//

current_client->borrow[i].starting=0;

current_client->borrow[i].nowstorage=0;

current_client->borrow[i].totalstorage=0;

current_client->borrow[i].writer[0]='\0';

printf("书已成功归还, 欢迎下次光临!\n");

}

/*注册模块*/

int registerer()

{

libcard *client,*client_temp=NULL;

char temp[13];

int type,success=0;

int i;

while(1){

while(1){

但允许相同密码

无穷大

client=(libcard*)malloc(sizeof(libcard));// 这里很重要 client->next=NULL; printf("------------按要求填写有关注册信息--------------\n"); printf("用户ID :"); scanf("%s",&client->userID); /* * 检测是否为重复注册 */ client_temp=clients; while(client_temp!=NULL) { if(!strcmp(client->userID , client_temp->userID))// 不允许相同ID break; client_temp=client_temp->next; } if(client_temp == NULL)// 没有相同的ID { /* * 注册成功后应对信息进行初始化 */ for(i=0;iborrow[i].bookinform[0] = '\0'; client->borrow[i].bookname[0] = '\0'; client->borrow[i].writer[0] = '\0'; client->borrow[i].callnum = 0; client->borrow[i].starting = 0; client->borrow[i].ending = 315360000;// 将归还日期初始为 client->borrow[i].nowstorage = 0; client->borrow[i].totalstorage = 0; } client->next=clients;

clients=client;

}

else

{

printf("对不起,该ID 已被占用, 注册失败!\n");

break;

}

while(1)

{

printf("密码:");

GetPassword(&client->password,12);

// scanf("%s",&client->password);

printf("确认密码:");

GetPassword(&temp,12);

// scanf("%s",&temp);

if(!strcmp(client->password,temp))// 检测密码是否有误 break;

printf("您的密码输入有误,请从新输入\n");

}

printf("请输入用户名字:");

scanf("%s",&client->clientname);

printf("请输入用户描述:");

scanf("%s",&client->usermessage);

break;

}

printf("是否继续注册?(1、继续)(0、退出)");

scanf("%d",&type);

if(!type)

break;

}

return success;

}

/*核对用户信息*/

int check_client(libcard **client)

{

int success=0;

libcard *temp=clients;

while(temp!=NULL ) //循环验证借书证

{

if(!strcmp((*client)->userID , temp->userID)&&!strcmp((*client)->password , temp->password)) //如果有其一不对应,则跳入下面一个用户验证 {

} free(*client); *client=temp; success=1; break; } temp=temp->next; } return success; /* * 客户 */ void clientsev(volume **Btroot) { int a,b; volume *temp; libcard *p=NULL;// 用作临时指针 if(current_client==NULL) { printf("您还未登录,请登录!\n"); login(); return;// 不管是否成功登陆都将返回原处 } while(1) { system("cls");// //////////清屏 printf("----------------- 图书管理系统 -----------------\n"); printf("-------------------客户用户---------------------\n"); printf(" --------------- 1、图书借阅--------------------\n"); printf(" --------------- 2、图书归还--------------------\n"); printf(" --------------- 0、退出------------------------\n"); scanf("%d",&a); switch(a) { case 1: printf("输入索书号:\n"); scanf("%d",&b); lend(Btroot,b);

} } break; case 2: printf("输入索书号:\n"); scanf("%d",&b); backbook(Btroot,b); break; default:return; } system("pause");// ////////////////////////// /* * 登录模块 返回登录的用户类型 用户必须先登录才能对图书进行操作 */ int login() { libcard *temp_client=NULL; int type,temp; printf("----------------- 图书管理系统-----------------\n"); printf("------------------客 户 登 录------------------\n"); printf("确认按1:"); scanf("%d",&type); while(1) { if(current_client!=NULL) { printf("对不起,登录人数已满,您目前还不能登陆!\n"); break; } temp_client = (libcard *)malloc(sizeof(libcard)); printf("请输入借阅证号:"); scanf("%s",&temp_client->userID); printf("请输入密码:"); GetPassword(&temp_client->password,12); // scanf("%s",&temp_client->password); if(check_client(&temp_client))// 调用函数检查 { current_client=temp_client; return type; } else {

printf("对不起,密码错误!\n");

free(temp_client);

current_client = NULL;

break;

}

}

printf("(0、退出)\n");

scanf("%d",&temp);

if(!temp)return 0;

}

/*

从键盘获取字符密码, 显示为*,设定最大字符数为n

*/

void GetPassword(char *str,int n)

{

int i=0;

char c;

while((c=getch())!=13&&i

{

if(c!=8)

{

putch('*');//回显*

str[i++]=c;

}

else

i--;

}

putch('\n');

str[i]='\0';

}

int tushuguanli()

{

int a=0,b,i;

int cases=0,goornot;

book booker;

volume root,*Btroot;

printf("---------------欢迎访问图书管理系统---------------\n"); printf("---------------初次用系统先建立书库---------------\n"); printf("---------------按照提示输入有关信息----------------\n");

/*

* 读取所有管理员和客户

*/

createBST(&Btroot);// 在系统启动时调出记录

while(1){

printf("---------------提示-----------------\n");

printf("----------按1继续添加图书-----------\n");

printf("----------其他进入系统界面----------\n");

scanf("%d",&i);

if(i==1)

in_stor(Btroot);

else

break;}

while(1)

{

system("cls");// //////////清屏

printf("----------------- 图书管理系统 -----------------\n"); printf("----------------- 选择您的操作 -----------------\n"); printf("------------------1、注 册-----------------------\n"); printf("------------------2、登 录-----------------------\n"); printf("------------------3.其他进入系统界面--------------\n"); cases=0;//

scanf("%d",&b);

switch(b)

{

case 1:

registerer();

break;

case 2:

cases=login();

default:break;

}

/*

* 选择登录的用户 本系统必须先登录才能操作 */

printf("-------------------图书管理系统 ------------------\n"); printf("-------------------选择您的操作 ------------------\n"); printf(" -----------------1、用户注册----------------------\n"); printf(" -----------------2、用户登录----------------------\n"); printf(" -----------------3、图书入库----------------------\n"); printf(" -----------------4、进入用户界面 -----------------\n"); scanf("%d:",&b);

switch(b)

{

case 1:

registerer();

break;

case 3:

in_stor(Btroot);

break;

case 2:

login();

break;

case 4:

clientsev(&Btroot);

default:break;

}

system("cls");// //////////清屏

printf("是否继续(1、继续)(0、退出)"); scanf("%d",&goornot);

if(!goornot)

break;

}

return 0;

}


相关内容

  • 图书馆信息管理系统
  • 图书馆信息管理系统 数据库的概念 数据库是一种存储数据并对数据进行操作的工具.数据库的作用在于组织和表达信息,简而言之,数据库就是信息的集合.计算机的数据库可以分为两类:非关系数据库(flat-file )和关系数据库(relational ).关系数据库中包含了多个数据表的信息,数据库含有各个不同 ...

  • 图书管理系统论文
  • 山 东 英 才 学 院 毕 业 论 文 论文题目: 图书管理系统 二 级 学 院: 计算机学院 学 科 专 业: 计算机信息管理 学 号: [1**********]0 姓 名: 冯志飞 班 级: 4班 指 导 教 师: 张立然 摘要: 管理信息系统是一个不断发展的新型学科,企业要生存要发展,要高效 ...

  • 太原理工大学毕业设计
  • 继续教育学院综合作业报告 二〇一〇年五月十五日 摘 要 本文首先介绍了数据库管理系统(DBMS )的基本概念及关系模型等.然后对问题的来源进行深入分析,指出图书借阅者.图书馆工作人员和图书馆管理人员是问题主要来源, 并指出本数据管理系统的实用性功能就是管理好图书馆信息,提高工作效率,避免数据处理手工 ...

  • 高校图书管理系统项目计划书
  • 高校图书管理系统 项目计划书 姓 名: 班 级: 学号: 目录 1. 图书管理系统需求分析 ........................................................................................................ ...

  • 图书管理系统心得
  • 为期两个星期的c#图书管理系统实习终于结束了,总算松了一口气,在这短短的两周时间内承受了很大的压力现在终于能够得到"释放"了,感觉到很轻松.回顾这两周所做过的工作和努力,感觉到收获不少,这里面除了实习本省的内容外,还包括许许多多超乎实习本身意义之外的东西. 说实话本来我多程序编写 ...

  • 图书管理系统小结
  • 为期两个星期的c#图书管理系统实习终于结束了,总算松了一口气,在这短短的两周时间内承受了很大的压力现在终于能够得到“释放”了,感觉到很轻松。回顾这两周所做过的工作和努力,感觉到收获不少,这里面除了实习本省的内容外,还包括许许多多超乎实习本身意义之外的东西。 说实话本来我多程序编写这相关的都不怎么感兴 ...

  • 网上书店系统毕业论文
  • 摘 要 当今Internet技术日新月异,电子商务作为一种新的商业趋势发展起来.它提供了全新的网上交易平台,方便了企业与客户之间的交流,提高了工作效率.随着生产社会化趋势的扩大.科学技术的进步.人类知识总量的增长速度不断加快.以及市场竞争的日益激烈,人们对信息的认识产生了根本性的变化. 本系统是一个 ...

  • 校园网站的设计与实现
  • 校园网站的设计与实现 摘 要 在Internet飞速发展的今天,互联网成为人们快速获取.发布和传递信息的重要渠道,它在人们政治.经济.生活等各个方面发挥着重要的作用.Internet上发布信息主要是通过网站来实现的,获取信息也是要在Internet"海洋"中按照一定的检索方式将所 ...

  • 网上书店设计与实现
  • 重庆大学网络教育学院 毕业设计(论文) 题目 网上书店设计与实现 学生所在校外学习中心 四川广安校外学习中心 批次 层次 专业 121专科起点本科 计算机科学与技术 学 号 W12111558 学 生 吴 清 指 导 教 师 屈 松 起 止 日 期 2013 年7月1日至 2013年8月21日止 摘 ...

  • 图书管理信息系统的设计和实现
  • 目录 图书管理信息系统的设计和实现 端应用程序的开发两个方面.对于前者要求建立起数据一致性和完整性强.数据安全性好的数据库.而对于后者则要求应用程序功能完备, 易使用等特点. 本图书管理信息系统是利用计算机管理信息处理的迅速.准确.可靠且具有强大存储能力的突出特点,全面提高图书馆的管理水平和工作效率 ...