皮皮网

【注册界面源码】【个人网站java源码下载】【asp图片网站源码】借阅系统源码_借阅系统源码怎么用

2024-11-23 13:23:44 来源:如何运行dbeaver源码

1.书馆借阅系统源代码
2.C语言实现图书管理系统
3.急求C语言编写的借阅借阅图书管理系统源代码,具体要求如下

借阅系统源码_借阅系统源码怎么用

书馆借阅系统源代码

       #include<stdio.h> #include<string.h> #include<conio.h> #include<stdlib.h> #include<ctype.h> #define STACK_INIT_SIZE #define OK 1 #define TRUE 1 #define FALSE 0 #define ERROR 0 struct student /*定义学生类型,系统系统用于存放借出的源码源码用书籍*/ { int carnum; char lendbook[]; }student[]; struct employ /*定义职工类型*/ { int employnum; char employname[]; int employage; char employsex[2]; char employleve[]; long int employtage; }employ[]; struct book /*定义书的类型*/ { int booknum; char bookname[]; char bookcreat[]; int turefalse; /*用于借书和还书模块判断一本书是否借出的条件*/ }book[]; struct car /*借书卡的数据类型*/ { int carnum; char studentname[]; int studentclass; }car[]; huanbook() /*还书函数*/ { FILE *fp,*fp2; /*定义两个文件指针,fp2用于修改数据时设立临时文件用,借阅借阅防止数据遭破坏*/ int i,系统系统n; int carnum; char lendbook[]; printf("请你输入你的卡号\n"); scanf("%d",&carnum); fp=fopen("car.txt","r"); /*读取卡号记录*/ for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++) /*for循环判断卡号是否存在*/ { if(car[i].carnum==carnum) /*卡号存在,进入下一循环*/ { n=i; fclose(fp); printf("请输入你要还的源码源码用注册界面源码书的名字\n"); scanf("%s",lendbook); fp=fopen("record.txt","r"); for(i=0;fread(&student[i],sizeof(struct student),1,fp)!=0;i++) /*判断是否借阅了输入的书*/ { if(strcmp(student[i].lendbook,lendbook)==0) /*借阅了该书,进入下一循环,借阅借阅否则出错显示*/ { fclose(fp); fp=fopen("record.txt",系统系统"r"); fp2=fopen("bookl.txt","w"); for(i=0;fread(&student[i],sizeof(struct student),1,fp)!=0;i++) { if(strcmp(student[i].lendbook,lendbook)==0) { continue; /*删除还掉的书的借书记录*/ } fwrite(&student[i],sizeof(struct student),1,fp2); /*写入原来没还的书的记录*/ } fclose(fp); fclose(fp2); fp=fopen("record.txt","w"); fp2=fopen("bookl.txt","r"); for(i=0;fread(&student[i],sizeof(struct student),1,fp2)!=0;i++) { fwrite(&student[i],sizeof(struct student),1,fp); /*将借书记录信息写回*/ } fclose(fp); fclose(fp2); fopen("bookl.txt","w"); /*清临时文件的记录*/ fclose(fp2); fp=fopen("book.txt","r"); fp2=fopen("bookl.txt","w"); for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++) /*将书的记录写入临时文件,防止因为修改信息破坏以前的源码源码用记录*/ { if(i==n) { book[i].turefalse=1; fwrite(&book[i],sizeof(struct book),1,fp2); /*将还的书的原来状态设为无人借阅的*/ continue; } fwrite(&book[i],sizeof(struct book),1,fp2); } fclose(fp); fclose(fp2); fp=fopen("book.txt","w"); fp2=fopen("bookl.txt","r"); for(i=0;fread(&book[i],sizeof(struct book),1,fp2)!=0;i++) { fwrite(&book[i],sizeof(struct book),1,fp); /*将临时文件写回*/ } fclose(fp); fclose(fp2); fopen("bookl.txt","w"); /*清临时文件*/ fclose(fp2); printf("还书完毕,按任意键返回\n"); getch(); return 1; } } printf("你没有借这样的借阅借阅书,任意键返回\n"); /*出错提示*/ fclose(fp); getch(); return 0; } } printf("系统没这样的系统系统卡,和管理员联系,源码源码用按任意键返回\n"); /*出错提示*/ fclose(fp); getch(); } findbook() { FILE *fp; char bookname[]; int ture,i; fp=fopen("book.txt","r"); printf("请输入你要查找的书名\n"); scanf("%s",bookname); for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++) { if(strcmp(bookname,book[i].bookname)==0) { if(book[i].turefalse==1) { printf("这本书的详细资料是:%d %s %s 此书现在无人借阅\n按任意键返回\n",book[i].booknum,book[i].bookname,book[i].bookcreat); } else { printf("这本书已经有人借出\n");fclose(fp);return 0;} fclose(fp); return FALSE; } } printf("没有你要查询的书籍\n"); fclose(fp); return FALSE; } findbook1() { FILE *fp; char bookcreat[]; int ture,i; fp=fopen("book.txt","r"); printf("请输入你要查找的作者名\n"); scanf("%s",bookcreat); for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++) { if(strcmp(bookcreat,book[i].bookcreat)==0) { if(book[i].turefalse==1) { printf("这本书的详细资料是:%d %s %s 此书现在无人借阅\n按任意键返回\n",book[i].booknum,book[i].bookname,book[i].bookcreat); } else { printf("这本书已经有人借出\n");fclose(fp);return 0;} fclose(fp); return FALSE; } } printf("没有你要查询的书籍\n"); fclose(fp); return FALSE; } lendcount() { FILE *fp; int i,n=0; fp=fopen("record.txt","r"); for(i=0;fread(&student[i],sizeof(struct student),1,fp)!=0;i++) { printf("卡号:%d 借出的书籍:%s \n",student[i].carnum,student[i].lendbook); n=n+1; } fclose(fp); printf("目前共有%d本书借出\n",n); printf("按任意键\n"); getch(); return n; } chabook() { char ch5; do { printf("---------------欢迎进入图书查询系统!--------------\n"); printf(" 1:<按书名查找>\n"); printf(" 2:<按作者查找>\n"); printf(" 0:<返回>\n"); printf("请输入0--2,借阅借阅其他输入非法!\n"); scanf("%s",系统系统&ch5); switch(ch5) { case '1':findbook();getch();break; case '2':findbook1();getch();break; case '0':break; default:printf("无此操作\n");getch();break; } }while(ch5!='0'); return FALSE; } lendbook() { FILE *fp,*fp2; int i,n; int carnum; printf("请你输入你的卡号\n"); scanf("%d",&carnum); fp=fopen("car.txt","r"); for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++) { if(car[i].carnum==carnum) { n=i; fclose(fp); printf("请输入你要借阅的书的名字\n"); scanf("%s",student[n].lendbook); fp=fopen("book.txt","r"); for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++) { if(strcmp(book[i].bookname,student[n].lendbook)==0) { if(book[i].turefalse==0) { printf("对不起,此书有人借出,源码源码用个人网站java源码下载请借其他书\n");fclose(fp);getch();return;} else fclose(fp); fp=fopen("record.txt","a+"); student[n].carnum=carnum; fwrite(&student[n],sizeof(struct student),1,fp); fclose(fp); fp=fopen("book.txt","r"); fp2=fopen("bookl.txt","w"); for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++) { if(strcmp(book[i].bookname,student[n].lendbook)==0) { book[i].turefalse=0; fwrite(&book[i],sizeof(struct book),1,fp2); continue; } fwrite(&book[i],sizeof(struct book),1,fp2); } fclose(fp); fclose(fp2); fp=fopen("book.txt","w"); fp2=fopen("bookl.txt","r"); for(i=0;fread(&book[i],sizeof(struct book),1,fp2)!=0;i++) { fwrite(&book[i],sizeof(struct book),1,fp); } fclose(fp); fclose(fp2); fopen("bookl.txt","w"); fclose(fp2); printf("借书完毕,按任意键返回\n"); getch(); return; } } printf("不存在这样的书,任意键返回\n"); fclose(fp); getch(); return; } } printf("你的卡号不存在,请申请新卡,按任意键返回\n"); fclose(fp); getch(); } carcount() { FILE *fp; int i,n=0; fp=fopen("car.txt","r"); for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++) { printf("第%d张卡<卡号:%d 姓名:%s 班级:%d>\n",i+1,car[i].carnum,car[i].studentname,car[i].studentclass); n=n+1; } fclose(fp); printf("目前共有%d本书\n",n); printf("按任意键\n"); getch(); } delcar() { FILE *fp,*fp2; int i; int carnum; char choice; fp=fopen("car.txt","r"); fp2=fopen("bookl.txt","w"); printf("请输入你要删除的卡号\n"); printf("如果你输入的卡号存在,系统自动删除该信息!如果不存在,系统不做任何改动\n"); scanf("%d",asp图片网站源码&carnum); for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++) { if(car[i].carnum!=carnum) { fwrite(&car[i],sizeof(struct car),1,fp2); } } fclose(fp); fclose(fp2); printf("是否真的要删除该卡?删除后该书籍的所有信息将无法恢复《Y/N》\n"); scanf("%s",&choice); if(choice=='y'||choice=='Y') { fp=fopen("car.txt","w"); fp2=fopen("bookl.txt","r"); for(i=0;fread(&car[i],sizeof(struct car),1,fp2)!=0;i++) { fwrite(&car[i],sizeof(struct car),1,fp); } fclose(fp); fclose(fp2); fp2=fopen("bookl.txt","w"); fclose(fp2); printf("按任意键返回\n"); getch(); return; } else { printf("按任意键返回\n"); getch(); return; } } addcar() { FILE *fp; int i=0; fp=fopen("car.txt","a+"); printf("请你输入卡号\n"); scanf("%d",&car[i].carnum); printf("请你输入学生姓名\n"); scanf("%s",car[i].studentname); printf("请你输入班级\n"); scanf("%d",&car[i].studentclass); fwrite(&car[i],sizeof(struct car),1,fp); fclose(fp); printf("输入完毕,任意键返回\n"); getch(); }

C语言实现图书管理系统

       å›¾ä¹¦ç®¡ç†ç³»ç»Ÿçš„c实现用于图书信息的管理。包括图书信息的创建、图书信息的打印、图书信息的查询、图书信息的修改、图书信息的删除。方便用户整理图书,查询图书。

       è¿™ä¸ªå›¾ä¹¦ç®¡ç†ç³»ç»Ÿæ˜¯ç”±å•é“¾è¡¨è¿™ä¸€æ•°æ®ç»“构实现的,板块包括图书信息的创建、打印、查询、修改、删除、以及图书价格的排序等组成。 代码后面也有注释的,基本很好理解的。

       ä¸‹é¢ä¸ºæºä»£ç ï¼š

#include <stdio.h>#include <stdlib.h>#include <string.h>//3.数据的设计//3.1程序的数据存储--->容器//3.2数据的结构 --->图书的信息struct bookInfo{ char name[];//书名float price;//书籍的价格int num;//书籍的数量};//定义链表struct Node{ struct bookInfo data;struct Node* next;};struct Node* list = NULL;//将链表声明成全局变量//创建表头:表头就是结构体变量struct Node* createHead(){ //动态内存申请struct Node* headNode = (struct Node*)malloc(sizeof(struct Node));//变量初始化headNode->next = NULL;return headNode;}//创建节点:为插入做准备// 把用户的数据变成结构体变量struct Node* createNode(struct bookInfo data){ struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));newNode->data = data;newNode->next = NULL;return newNode;}//数据插入(头插法)void insertNodeByHead(struct Node* headNode, struct bookInfo data){ struct Node* newNode = createNode(data);newNode->next = headNode->next;headNode->next = newNode;}//尾插法/*struct insertNodeByTall(struct Node* headNode, int data){ struct Node* pMove = headNode;while (pMove != NULL){ pMove = pMove->next;}struct Node* newNode = createHead(data);pMove->next = newNode;}*///指定删除(删除链表中元素)//posLeftNode->next=posNode->next;//free(posNode);void deleteNodeByName(struct Node* headNode, char* bookname){ struct Node* posLeftNode = headNode;struct Node* posNode = headNode->next;//书籍名字是字符串,字符串比较函数while (posNode != NULL && strcmp(posNode->data.name, bookname)){ posLeftNode = posNode;posNode = posLeftNode->next;}//讨论查找的结果if (posNode == NULL)return;else{ printf("删除成功!\n");posLeftNode->next = posNode->next;free(posNode);posNode = NULL;}}//查找struct Node* searchByName(struct Node* headNode, char* bookName){ struct Node* posNode = headNode->next;while (posNode != NULL && strcmp(posNode->data.name, bookName)){ posNode = posNode->next;}return posNode;}//打印链表void printList(struct Node* headNode){ struct Node* pMove = headNode->next;printf("书名\t价格\t数量\n");while (pMove != NULL){ printf("%s\t%.1f\t%d\n", pMove->data.name, pMove->data.price, pMove->data.num);pMove = pMove->next;}}//直接文件操作//文件写操作void saveInfoToFile(const char* filename, struct Node* headNode){ FILE* fp = fopen(filename, "w");struct Node* pMove = headNode->next;while (pMove != NULL){ fprintf(fp, "%s\t%.1f\t%d\n", pMove->data.name, pMove->data.price, pMove->data.num);pMove = pMove->next;}fclose(fp);}//文件读操作void readInfoFromFile(const char* fileName, struct Node* headNode){ FILE* fp = fopen(fileName, "r");if (fp == NULL){ //不存在就创建出来这个文件fp = fopen(fileName, "w+");}struct bookInfo tempData;while (fscanf(fp, "%s\t%f\t%d\n", tempData.name, &tempData.price, &tempData.num) != EOF){ insertNodeByHead(list, tempData);}fclose(fp);}//冒泡排序(链表)void bubbleSortList(struct Node* headNode){ for (struct Node* p = headNode->next; p != NULL; p = p->next){ for (struct Node* q = headNode->next; q->next != NULL; q = q->next){ if (q->data.price > q->next->data.price){ //交换值struct bookInfo tempData = q->data;q->data = q->next->data;q->next->data = tempData;}}}printList(headNode);}//2.交互void keyDown(){ int userkey = 0;struct bookInfo tempBook;//产生一个临时的变量存储书籍信息struct Node* result = NULL;scanf("%d", &userkey);switch (userkey) { case 0:printf(" 【 登记 】 \n");printf("输入书籍的信息(name,price,num):");scanf("%s%f%d", tempBook.name, &tempBook.price, &tempBook.num);insertNodeByHead(list, tempBook);saveInfoToFile("bookinfo.txt", list);break;case 1:printf(" 【 浏览 】 \n");printList(list);break;case 2:printf(" 【 借阅 】 \n"); printf("请输入你要借阅的书籍:");scanf("%s", tempBook.name);result = searchByName(list,tempBook.name);if (result == NULL)printf("没有相关书籍无法借阅!\n");else{ if (result->data.num > 0){ result->data.num--;printf("借阅成功\n");saveInfoToFile("bookinfo.txt", list);}else{ printf("当前书籍无库存,借阅失败!\n");}}break;case 3:printf(" 【 归还 】 \n");printf("请输入你要归还的书籍:");scanf("%s", tempBook.name);result = searchByName(list, tempBook.name);if (result == NULL)printf("书籍来源非法!\n");else{ result->data.num++;printf("书籍归还成功!\n");saveInfoToFile("bookinfo.txt", list);}break;case 4:printf(" 【 查找 】 \n");printf("你要查询的书名:");scanf("%s", tempBook.name);result = searchByName(list, tempBook.name);if (result == NULL){ printf("未找到相关结果!\n");}else{ printf("书名\t价格\t数量\n");printf("%s\t%.1f\t%d\n", result->data.name, result->data.price, result->data.num);}break;case 5:printf(" 【 排序 】 \n");bubbleSortList(list);break;case 6:printf(" 【 删除 】 \n");printf("输入想要删除的书名:");scanf("%s", tempBook.name);deleteNodeByName(list, tempBook.name);saveInfoToFile("bookinfo.txt", list);break;case 7:printf(" 【 退出 】 \n");printf(" 退出成功 \n");system("pause");exit(0); //关掉整个程序break;default:printf(" 【 error 】 \n");break;}}//1.界面--->菜单--->模块void makeMenu(){ printf("----------------------------------\n");printf("Eugeo图书管理借阅系统\n");printf("t0.登记书籍\n");printf("t1.浏览书籍\n");printf("t2.借阅书籍\n");printf("t3.归还书籍\n");printf("t4.查找书籍\n");printf("t5.排序书籍\n");printf("t6.删除书籍\n");printf("t7.退出系统\n");printf("----------------------------------\n");printf("请输入(0~7):");}int main(){ list = createHead();//链表初始化readInfoFromFile("bookinfo.txt", list);while (1){ makeMenu();keyDown();system("pause");system("cls");}}原文:/post/

急求C语言编写的图书管理系统源代码,具体要求如下

       /*这有个以前用过的程序,你可以自己改改使用,但是有些功

       能好像有问题,会中断运行。至于程序的缩进式格式就你自己

       敲回车和退格解决吧,不然代码看起来会很乱不好看。java财务软件源码*/

       #include<stdio.h>

       #include<string.h>

       #include<conio.h>

       #include<stdlib.h>

       #include<ctype.h>

       #define STACK_INIT_SIZE

       #define OK 1

       #define TRUE 1

       #define FALSE 0

       #define ERROR 0

       struct student /*定义学生类型,用于存放借出的书籍*/

       {

       int carnum;

       char lendbook[];

       }student[];

       struct employ /*定义职工类型*/

       {

       int employnum;

       char employname[];

       int employage;

       char employsex[2];

       char employleve[];

       long int employtage;

       }employ[];

       struct book /*定义书的类型*/

       {

       int booknum;

       char bookname[];

       char bookcreat[];

       int turefalse; /*用于借书和还书模块判断一本书是否借出的条件*/

       }book[];

       struct car /*借书卡的数据类型*/

       {

       int carnum;

       char studentname[];

       int studentclass;

       }car[];

       huanbook() /*还书函数*/

       {

       FILE *fp,*fp2; /*定义两个文件指针,fp2用于修改数据时设立临时文件用,防止数据遭破坏*/

       int i,n;

       int carnum;

       char lendbook[];

       printf("请你输入你的卡号\n");

       scanf("%d",&carnum);

       fp=fopen("car.txt","r"); /*读取卡号记录*/

       for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++) /*for循环判断卡号是否存在*/

       {

        if(car[i].carnum==carnum) /*卡号存在,进入下一循环*/

        {

        n=i;

        fclose(fp);

        printf("请输入你要还的书的名字\n");

        scanf("%s",lendbook);

        fp=fopen("record.txt","r");

        for(i=0;fread(&student[i],sizeof(struct student),1,fp)!=0;i++) /*判断是否借阅了输入的书*/

        {

        if(strcmp(student[i].lendbook,lendbook)==0) /*借阅了该书,进入下一循环,否则出错显示*/

        {

        fclose(fp);

        fp=fopen("record.txt",基于jsp的系统源码"r");

        fp2=fopen("bookl.txt","w");

        for(i=0;fread(&student[i],sizeof(struct student),1,fp)!=0;i++)

        {

        if(strcmp(student[i].lendbook,lendbook)==0)

        {

        continue; /*删除还掉的书的借书记录*/

        }

        fwrite(&student[i],sizeof(struct student),1,fp2); /*写入原来没还的书的记录*/

        }

        fclose(fp);

        fclose(fp2);

        fp=fopen("record.txt","w");

        fp2=fopen("bookl.txt","r");

        for(i=0;fread(&student[i],sizeof(struct student),1,fp2)!=0;i++)

        {

        fwrite(&student[i],sizeof(struct student),1,fp); /*将借书记录信息写回*/

        }

        fclose(fp);

        fclose(fp2);

        fopen("bookl.txt","w"); /*清临时文件的记录*/

        fclose(fp2);

        fp=fopen("book.txt","r");

        fp2=fopen("bookl.txt","w");

        for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++) /*将书的记录写入临时文件,防止因为修改信息破坏以前的记录*/

        {

        if(i==n)

        {

        book[i].turefalse=1;

        fwrite(&book[i],sizeof(struct book),1,fp2); /*将还的书的原来状态设为无人借阅的*/

        continue;

        }

        fwrite(&book[i],sizeof(struct book),1,fp2);

        }

        fclose(fp);

        fclose(fp2);

        fp=fopen("book.txt","w");

        fp2=fopen("bookl.txt","r");

        for(i=0;fread(&book[i],sizeof(struct book),1,fp2)!=0;i++)

        {

        fwrite(&book[i],sizeof(struct book),1,fp); /*将临时文件写回*/

        }

        fclose(fp);

        fclose(fp2);

        fopen("bookl.txt","w"); /*清临时文件*/

        fclose(fp2);

        printf("还书完毕,按任意键返回\n");

        getch();

        return 1;

        }

        }

        printf("你没有借这样的书,任意键返回\n"); /*出错提示*/

        fclose(fp);

        getch();

        return 0;

        }

       }

       printf("系统没这样的卡,和管理员联系,按任意键返回\n"); /*出错提示*/

       fclose(fp);

       getch();

       }

       findbook()

       {

       FILE *fp;

       char bookname[];

       int ture,i;

       fp=fopen("book.txt","r");

       printf("请输入你要查找的书名\n");

       scanf("%s",bookname);

       for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)

       {

        if(strcmp(bookname,book[i].bookname)==0)

        {

        if(book[i].turefalse==1)

        {

        printf("这本书的详细资料是:%d %s %s 此书现在无人借阅\n按任意键返回\n",book[i].booknum,book[i].bookname,book[i].bookcreat);

        }

        else { printf("这本书已经有人借出\n");fclose(fp);return 0;}

        fclose(fp);

        return FALSE;

        }

       }

       printf("没有你要查询的书籍\n");

       fclose(fp);

       return FALSE;

       }

       findbook1()

       {

       FILE *fp;

       char bookcreat[];

       int ture,i;

       fp=fopen("book.txt","r");

       printf("请输入你要查找的作者名\n");

       scanf("%s",bookcreat);

       for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)

       {

        if(strcmp(bookcreat,book[i].bookcreat)==0)

        {

        if(book[i].turefalse==1)

        {

        printf("这本书的详细资料是:%d %s %s 此书现在无人借阅\n按任意键返回\n",book[i].booknum,book[i].bookname,book[i].bookcreat);

        }

        else { printf("这本书已经有人借出\n");fclose(fp);return 0;}

        fclose(fp);

        return FALSE;

        }

       }

       printf("没有你要查询的书籍\n");

       fclose(fp);

       return FALSE;

       }

       lendcount()

       {

       FILE *fp;

       int i,n=0;

       fp=fopen("record.txt","r");

       for(i=0;fread(&student[i],sizeof(struct student),1,fp)!=0;i++)

       {

        printf("卡号:%d 借出的书籍:%s \n",student[i].carnum,student[i].lendbook);

        n=n+1;

       }

       fclose(fp);

       printf("目前共有%d本书借出\n",n);

       printf("按任意键\n");

       getch();

       return n;

       }

       chabook()

       {

       char ch5;

       do

       {

       printf("---------------欢迎进入图书查询系统!--------------\n");

       printf(" 1:<按书名查找>\n");

       printf(" 2:<按作者查找>\n");

       printf(" 0:<返回>\n");

       printf("请输入0--2,其他输入非法!\n");

       scanf("%s",&ch5);

       switch(ch5)

        {

        case '1':findbook();getch();break;

        case '2':findbook1();getch();break;

        case '0':break;

        default:printf("无此操作\n");getch();break;

        }

       }while(ch5!='0');

       return FALSE;

       }

       lendbook()

       {

       FILE *fp,*fp2;

       int i,n;

       int carnum;

       printf("请你输入你的卡号\n");

       scanf("%d",&carnum);

       fp=fopen("car.txt","r");

       for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++)

       {

        if(car[i].carnum==carnum)

        {

        n=i;

        fclose(fp);

        printf("请输入你要借阅的书的名字\n");

        scanf("%s",student[n].lendbook);

        fp=fopen("book.txt","r");

        for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)

        {

        if(strcmp(book[i].bookname,student[n].lendbook)==0)

        {

        if(book[i].turefalse==0) { printf("对不起,此书有人借出,请借其他书\n");fclose(fp);getch();return;}

        else

        fclose(fp);

        fp=fopen("record.txt","a+");

        student[n].carnum=carnum;

        fwrite(&student[n],sizeof(struct student),1,fp);

        fclose(fp);

        fp=fopen("book.txt","r");

        fp2=fopen("bookl.txt","w");

        for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)

        {

        if(strcmp(book[i].bookname,student[n].lendbook)==0)

        {

        book[i].turefalse=0;

        fwrite(&book[i],sizeof(struct book),1,fp2);

        continue;

        }

        fwrite(&book[i],sizeof(struct book),1,fp2);

        }

        fclose(fp);

        fclose(fp2);

        fp=fopen("book.txt","w");

        fp2=fopen("bookl.txt","r");

        for(i=0;fread(&book[i],sizeof(struct book),1,fp2)!=0;i++)

        {

        fwrite(&book[i],sizeof(struct book),1,fp);

        }

        fclose(fp);

        fclose(fp2);

        fopen("bookl.txt","w");

        fclose(fp2);

        printf("借书完毕,按任意键返回\n");

        getch();

        return;

        }

        }

        printf("不存在这样的书,任意键返回\n");

        fclose(fp);

        getch();

        return;

        }

       }

       printf("你的卡号不存在,请申请新卡,按任意键返回\n");

       fclose(fp);

       getch();

       }

       carcount()

       {

       FILE *fp;

       int i,n=0;

       fp=fopen("car.txt","r");

       for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++)

       {

        printf("第%d张卡<卡号:%d 姓名:%s 班级:%d>\n",i+1,car[i].carnum,car[i].studentname,car[i].studentclass);

        n=n+1;

       }

       fclose(fp);

       printf("目前共有%d本书\n",n);

       printf("按任意键\n");

       getch();

       }

       delcar()

       {

       FILE *fp,*fp2;

       int i;

       int carnum;

       char choice;

       fp=fopen("car.txt","r");

       fp2=fopen("bookl.txt","w");

       printf("请输入你要删除的卡号\n");

       printf("如果你输入的卡号存在,系统自动删除该信息!如果不存在,系统不做任何改动\n");

       scanf("%d",&carnum);

       for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++)

       {

        if(car[i].carnum!=carnum)

        {

        fwrite(&car[i],sizeof(struct car),1,fp2);

        }

       }

       fclose(fp);

       fclose(fp2);

       printf("是否真的要删除该卡?删除后该书籍的所有信息将无法恢复《Y/N》\n");

       scanf("%s",&choice);

       if(choice=='y'||choice=='Y')

       {

        fp=fopen("car.txt","w");

        fp2=fopen("bookl.txt","r");

        for(i=0;fread(&car[i],sizeof(struct car),1,fp2)!=0;i++)

        {

        fwrite(&car[i],sizeof(struct car),1,fp);

        }

        fclose(fp);

        fclose(fp2);

        fp2=fopen("bookl.txt","w");

        fclose(fp2);

        printf("按任意键返回\n");

        getch();

        return;

       }

       else

       {

        printf("按任意键返回\n");

        getch();

        return;

       }

       }

       addcar()

       {

       FILE *fp;

       int i=0;

       fp=fopen("car.txt","a+");

       printf("请你输入卡号\n");

       scanf("%d",&car[i].carnum);

       printf("请你输入学生姓名\n");

       scanf("%s",car[i].studentname);

       printf("请你输入班级\n");

       scanf("%d",&car[i].studentclass);

       fwrite(&car[i],sizeof(struct car),1,fp);

       fclose(fp);

       printf("输入完毕,任意键返回\n");

       getch();

       }

       changemploy()

       {

       FILE *fp,*fp2;

       char employname[],choice;

       int i;

       fp=fopen("employ.txt","r");

       fp2=fopen("bookl.txt","w");

       printf("请你输入要修改的职工的名字\n");

       scanf("%s",employname);

       for(i=0;fread(&employ[i],sizeof(struct employ),1,fp)!=0;i++)

       {

        if(strcmp(employ[i].employname,employname)==0)

        {

        printf("你所要修改的职工的资料如下,请选择你要修改的内容\n");

        printf("<职工号:%d职工名:%s 年龄:%d 性别:%s 学历:%s 工资:%d>\n",employ[i].employnum,employ[i].employname,employ[i].employage,employ[i].employsex,employ[i].employleve,employ[i].employtage);

        printf("2:修改职工名\n");

        printf("3:修改职工年龄\n");

        printf("4:修改职工工资\n");

        printf("5:修改职工学历\n");

        printf("请输入1-5:");

        scanf("%s",&choice);

        switch(choice)

        {

        case '1':

        {

        printf("请输入新的职工号\n");

        scanf("%d",&employ[i].employnum);

        fwrite(&employ[i],sizeof(struct employ),1,fp2);

        }break;

        case '2':

        {

        printf("请输入新的职工姓名\n");

        scanf("%s",employ[i].employname);

        fwrite(&employ[i],sizeof(struct employ),1,fp2);

        }break;

        case '3':

        {

        printf("请输入新的年龄\n");

        scanf("%d",&employ[i].employage);

        fwrite(&employ[i],sizeof(struct employ),1,fp2);

        }break;

        case '4':

        {

        printf("请输入新的职工工资\n");

        scanf("%d",&employ[i].employtage);

        fwrite(&employ[i],sizeof(struct employ),1,fp2);

        }break;

        case '5':

        {

        printf("请输入新的职工学历\n");

        scanf("%s",employ[i].employleve);

        fwrite(&employ[i],sizeof(struct employ),1,fp2);

        }

        default:printf("没有这样的操作");break;

        }

        continue;

        }

        fwrite(&employ[i],sizeof(struct employ),1,fp2);

       }

       fclose(fp);

       fclose(fp2);

       fp=fopen("employ.txt","w");

       fp2=fopen("bookl.txt","r");

       for(i=0;fread(&employ[i],sizeof(struct employ),1,fp2)!=0;i++)

        {

        fwrite(&employ[i],sizeof(struct employ),1,fp);

        }

       fclose(fp);

       fclose(fp2);

       fp2=fopen("bookl.txt","w");

       fclose(fp2);

       printf("按任意键返回\n");

       getchar();

       return;

       }

       delemploy()

       {

       FILE *fp,*fp2;

       int i;

       char employname[],choice;

       fp=fopen("employ.txt","r");

       fp2=fopen("bookl.txt","w");

       printf("请输入你要删除的职工名\n");

       printf("如果你输入的职工存在,系统自动删除该信息!如果不存在,系统不做任何改动\n");

       scanf("%s",employname);

       for(i=0;fread(&employ[i],sizeof(struct employ),1,fp)!=0;i++)

       {

        if(strcmp(employname,employ[i].employname)!=0)

        {

        fwrite(&employ[i],sizeof(struct employ),1,fp2);

        }

       }

       fclose(fp);

       fclose(fp2);

       printf("是否真的要删除该职工信息?删除后的所有信息将无法恢复《Y/N》\n");

       scanf("%s",&choice);

       if(choice=='y'||choice=='Y')

       {

        fp=fopen("employ.txt","w");

        fp2=fopen("bookl.txt","r");

        for(i=0;fread(&employ[i],sizeof(struct employ),1,fp2)!=0;i++)

        {

        fwrite(&employ[i],sizeof(struct employ),1,fp);

        }

        fclose(fp);

        fclose(fp2);

        fp2=fopen("bookl.txt","w");

        fclose(fp2);

        printf("按任意键返回\n");

        getch();

        return TRUE;

       }

       else

       {

       printf("按任意键返回\n");

       getch();

       return FALSE;

       }

       }

       employcount()

       {

       FILE *fp;

       int i,n=0;

       fp=fopen("employ.txt","r");

       for(i=0;fread(&employ[i],sizeof(struct employ),1,fp)!=0;i++)

       {

        printf("第%d职工的信息如下:\n<职工号:%d 职工名:%s 年龄:%d 性别:%s 学历:%s 工资:%d>\n",n+1,employ[i].employnum,employ[i].employname,employ[i].employage,employ[i].employsex,employ[i].employleve,employ[i].employtage);

        n++;

       }

       fclose(fp);

       printf("目前共有%d个职工\n",n);

       printf("按任意键返回\n");

       }

       addemploy()

       {

       FILE *fp;

       char choice='y';

       int i=1;

       fp=fopen("employ.txt","a+");

       while(choice=='y'||choice=='Y')

       {

        printf("请你输入职工号码\n");

        scanf("%d",&employ[i].employnum);

        printf("请你输入职工名\n");

        scanf("%s",employ[i].employname);

        printf("请输入职工年龄\n");

        scanf("%d",&employ[i].employage);

        printf("请你输入性别\n");

        scanf("%s",employ[i].employsex);

        printf("请你输入职工的学历水平\n");

        scanf("%s",employ[i].employleve);

        printf("请输入职工的工资\n");

        scanf("%d",&employ[i].employtage);

        fwrite(&employ[i],sizeof(struct employ),1,fp);

        printf("是否要输入下个职工信息?\n");

        scanf("%s",&choice);

       }

       printf("按任意键返回\n");

       fclose(fp);

       }

       addbook()

       {

       FILE *fp;

       int i=0;

       char choice='y';

       fp=fopen("book.txt","a+");

       while(choice=='y'||choice=='Y')

       {

        printf("请你输入第%d本书的序号\n",i+1);

        scanf("%d",&book[i].booknum);

        printf("请你输入书名\n");

        scanf("%s",book[i].bookname);

        printf("请你输入书的作者\n");

        scanf("%s",book[i].bookcreat);

        printf("请设为1或0,1代表书还没人借,0表示书已经借出,设其他值,程序运行时无法得出正常结果\n");

        printf("请你设定书的状态\n");

        scanf("%d",&book[i].turefalse);

        fwrite(&book[i],sizeof(struct book),1,fp);

        printf("是否要输入下本书\n");

        scanf("%s",&choice);

       }

       fclose(fp);

       }

       bookcount()

       {

       FILE *fp;

       int i,n=0;

       fp=fopen("book.txt","r");

       for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)

       {

        if(book[i].booknum!=0&&strlen(book[i].bookname)!=0&&strlen(book[i].bookcreat)!=0)

        {

        printf("第%d本书<序号:%d 书名:%s 作者:%s 状态:%d>\n",i+1,book[i].booknum,book[i].bookname,book[i].bookcreat,book[i].turefalse);

        n=n+1;

        }

       }

       fclose(fp);

       printf("目前共有%d本书\n",n);

       printf("按任意键\n");

       }

       delbook()

       {

       FILE *fp,*fp2;

       int i;

       char bookname[],choice;

       fp=fopen("book.txt","r");

       fp2=fopen("bookl.txt","w");

       printf("请输入你要删除的书名\n");

       printf("如果你输入的书名存在,系统自动删除该信息!如果不存在,系统不做任何改动\n");

       scanf("%s",bookname);

       for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)

       {

        if(strcmp(bookname,book[i].bookname)!=0)

        {

        fwrite(&book[i],sizeof(struct book),1,fp2);

        }

       }

       fclose(fp);

       fclose(fp2);

       printf("是否真的要删除该书籍?删除后该书籍的所有信息将无法恢复《Y/N》\n");

       scanf("%s",&choice);

       if(choice=='y'||choice=='Y')

       {

        fp=fopen("book.txt","w");

        fp2=fopen("bookl.txt","r");

        for(i=0;fread(&book[i],sizeof(struct book),1,fp2)!=0;i++)

        {

        fwrite(&book[i],sizeof(struct book),1,fp);

        }

        fclose(fp);

        fclose(fp2);

        fp2=fopen("bookl.txt","w");

        fclose(fp2);

        printf("按任意键返回\n");

        getch();

        return;

       }

       else

       {

        printf("按任意键返回\n");

        getch();

        return;

       }

       }

       changebook()

       {

       FILE *fp,*fp2;

       char bookname[],choice;

       int i;

       fp=fopen("book.txt","r");

       fp2=fopen("bookl.txt","w");

       printf("请你输入要修改的书籍的书字\n");

       scanf("%s",bookname);

       for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)

       {

        if(strcmp(book[i].bookname,bookname)==0)

        {

        printf("你所要修改的书的资料如下,请选择你要修改的内容\n");

        printf("序号:〈%d〉 书名:〈%s〉 作者:〈%s〉 \n",book[i].booknum,book[i].bookname,book[i].bookcreat);

        printf("1:修改书的序号\n");

        printf("2:修改书名\n");

        printf("3:修改作者\n");

        printf("请输入1-3:");

        scanf("%s",&choice);

        switch(choice)

        {

        case '1':

        {

        printf("请输入新的序号\n");

        scanf("%d",&book[i].booknum);

        fwrite(&book[i],sizeof(struct book),1,fp2);

        }break;

        case '2':

        {

        printf("请输入新的书名\n");

        scanf("%s",book[i].bookname);

        fwrite(&book[i],sizeof(struct book),1,fp2);

        }break;

        case '3':

        {

        printf("请输入新的作者\n");

        scanf("%s",book[i].bookcreat);

        fwrite(&book[i],sizeof(struct book),1,fp2);

        }break;

        defaut:printf("没有这样的操作");break;

        }

        continue;

        }

        fwrite(&book[i],sizeof(struct book),1,fp2);

       }

       fclose(fp);

       fclose(fp2);

       fp=fopen("book.txt","w");

       fp2=fopen("bookl.txt","r");

       for(i=0;fread(&book[i],sizeof(struct book),1,fp2)!=0;i++)

       {

        fwrite(&book[i],sizeof(struct book),1,fp);

       }

       fclose(fp2);

       fp2=fopen("bookl.txt","w");

       fclose(fp2);

       printf("按任意键返回\n");

       getchar();

       return;

       }

       main()

       {

       char ch1,ch2,ch3,ch4,ch5;

       do

       {

        printf("\t\t请你选择操作类型:\n");

        printf(" 1:<查阅图书>\n");

        printf(" 2:<借阅图书>\n");

        printf(" 3:<管理系统>\n");

        printf(" 4:<还书>\n");

        printf(" 0:<退出>\n");

        printf("请输入0--4\n");

        scanf("%s",&ch1);

        switch(ch1)

        {

        case '1':chabook();break;

        case '2':lendbook();;break;

        case '3':{

        do

        {

        printf("---------------欢迎进入管理系统!--------------\n");

        printf(" 1:<增加图书>\n");

        printf(" 2:<删除图书>\n");

        printf(" 3:<修改图书资料>\n");

        printf(" 4:<书籍统计>\n");

        printf(" 5:<职工管理系统>\n");

        printf(" 6:<学生管理系统>\n");

        printf(" 0:<返回>\n");

        printf("请输入0--6,其他输入非法!\n");

        scanf("%s",&ch2);

        switch(ch2)

        {

        case '1':addbook();

        break;

        case '2':delbook();break;

        case '3':changebook();break;

        case '4':bookcount();getch();break;

        case '5':{ do

        {

        printf("---------------欢迎进入职工管理系统!--------------\n");

        printf(" 1:<增加员工>\n");

        printf(" 2:<删除员工>\n");

        printf(" 3:<修改员工资料>\n");

        printf(" 4:<员工统计>\n");

        printf(" 0:<返回>\n");

        printf("请输入0--4,其他输入非法!\n");

        scanf("%s",&ch3);

        switch(ch3)

        {

        case '1':addemploy();getch();break;

        case '2':delemploy();break;

        case '3':changemploy();break;

        case '4':employcount();getch();break;

        case '0':break;

        default:printf("无此操作\n");getch();break;

       }

       }while(ch3!='0');}break;

       case '6':{

       do

       {

       printf("---------------欢迎进入学生管理系统!--------------\n");

       printf(" 1:<申请新卡>\n");

       printf(" 2:<删除卡号>\n");

       printf(" 3:<借书统计>\n");

       printf(" 4:<卡号统计>\n");

       printf(" 0:<返回>\n");

       printf("请输入0--4,其他输入非法!\n");

       scanf("%s",&ch4);

       switch(ch4)

       {

       case '1':addcar();break;

       case '2':delcar();break;

       case '3':lendcount();break;

       case '4':carcount();break;

       case '0':break;

       default:printf("无此操作\n");getch();break;

       }

       }while(ch4!='0');}break;

       case '0':break;

       default:printf("无此操作\n");getch();break;

       }

       }while(ch2!='0');}break;

       case '4':huanbook();break;

       case '0':break;

       default:printf("无此操作\n");getch();break;

       }

       }while(ch1!='0');

       }