三九宝宝网宝宝教育教学论文

c语言图书管理系统代码

01月04日 编辑 39baobao.com

[C语言图书管理系统]原发布者:天使小白很黑 图书管理系统设计图书管理信息包括:图书名称、图书编号、单价、作者、存在状态、借书人姓名、性别、学号等功能描述:1.新进熟土基本信息地输入2.图书基...+阅读

#include#include#include#include#include#define STACK_INIT_SIZE 10 #define OK 1 #define TRUE 1 #define FALSE 0 #define ERROR 0struct student /*定义学生类型,用于存放借出的书籍*/ { int carnum; char lendbook[10]; }student[1000];struct employ /*定义职工类型*/ { int employnum; char employname[15]; int employage; char employsex[2]; char employleve[10]; long int employtage; }employ[50];struct book /*定义书的类型*/ { int booknum; char bookname[10]; char bookcreat[10]; int turefalse; /*用于借书和还书模块判断一本书是否借出的条件*/ }book[1000];struct car /*借书卡的数据类型*/ { int carnum; char studentname[10]; int studentclass; }car[100];huanbook() /*还书函数*/ { FILE *fp,*fp2; /*定义两个文件指针,fp2用于修改数据时设立临时文件用,防止数据遭破坏*/ int i,n; int carnum; char lendbook[10]; 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[10]; 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[10]; 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,其他...

以下为关联文档:

图书信息管理程序用C语言编写#include#include#include#include#include#define STACK_INIT_SIZE 10 #define OK 1 #define TRUE 1 #define FALSE 0 #define ERROR 0 struct student /*定义学生类型,用于...

C语言图书信息管理系统原发布者:佴卬茕 HUNANUNIVERSITYC语言程序训练报告【设计目的】图书信息包括:读者登录号、管理员登录号、图书编号、作者名、种类、出版社、图书库存、图书借出数目等.图书...

图书信息管理系统设计 c语言高级语言程序设计(2)课程设计 一程序设计说明书【设计题目】图书馆借阅管理【问题描述】图书馆,适合用C++面向对象的功能来描述。图书馆管理系统分为借书、还书、图书管理和读...

用C语言编写一个简单的图书管理小程序源代码如下: #include<iostream> #include<iomanip> #include<string> #include<fstream> #include<stdio.h> using namespace std; const int maxb=10000; //最多的图书 clas...

如何使用C语言编写图书管理系统图书管理系统是运行于Windows系统下的应用软件,主要用于对图书馆中的图书信息进行增、删、改、查等操作,并且还可对使用该系统的用户进行登录名和密码的管理等。系统给用户提...

急求c语言程序设计图书管理系统源代码#include#include#include#include#define N 100 //书籍的最多本数 struct book { char title[30]; int number; char author[30]; float price; int store; char borrower_...

求C语言图书馆管理程序汗.第二个要这个的人..12小时内碰到俩啦 #include#include#include// #define MAXSIZE 100 //最大值定义为100 #define LIST_INIT_SIZE 100//图书证使用者最大值定义为100 /...

用C语言编一个简单的图书管理系统包括借阅查询还书三部分学展开全部#include#include struct sale/*商品名的定义*/ {int number; char name[20]; float price; long count; long time; long date;}; /*各个函数*/ void input(struct s...

一个简单的图书管理系统 C语言#include#include int function1(); int function2(); int function3(); int function4(); int function5(); int function6(); int function7(); int function8(); int mai...

推荐阅读
图文推荐