大家好,今日小爱来为大家解答以上的问题。c语言图书管理系统,c语言图书管理系统源代码很多人还不知道,现在让我们一起来看看吧!

c语言图书管理系统 c语言图书管理系统源代码c语言图书管理系统 c语言图书管理系统源代码


c语言图书管理系统 c语言图书管理系统源代码


1、{Link ll;好了,希望能够帮到您。

2、如果你真的要纯c的话,只需要改一下输入输出就可。

3、即:cin,cout改为scanf,printf。

4、//Memory Time// 1347K 0MS// by : Snarl_j#include#include#include#include#include#include#include#include#include#include#define N 1000010#define LL long longusing namespace std;#include#include#include#includeusing namespace std;const int Maxb=10000; //最多的图书class Book//图书类{int tag; //删除标记1:已删0:未删int number; //ISBN书号char name[20]; //书名char author[10]; //主编char number2[10];//版次char ition[20];//出版社char time[20];//出版年int pr;//定价int onshelf; //是否在架1:在架0:已借public:Book() {}char getname() { return name; } //获取姓名int getnumber() { return number; } //获取ISBN书号int gettag() { return tag; } //获取删除标记char getauthor() {return author;} //获取主编char getnumber2() {return number2;} //获取版次char getition() {return ition;} //获取出版社char gettime() {return time;} //获取出版年char getpr() {return pr;} //获取图书定价void delbook() { tag=1; } //删除图书void addbook(int n,char na,char au,char n2,char da,char ti,int pr) //增加图书{tag=0;number=n;pr=pr;strcpy(name,na);strcpy(author,au);strcpy(number2,n2);strcpy(ition,da);strcpy(time,ti);onshelf=1;} void disp() //输出图书{cout class BDatabase //图书库类{int top; //图录指针Book book[Maxb]; //图录public:BDatabase() //构造函数,将book.txt读到book[]中{Book b;top=-1;fstream file("book.txt",ios::in);while (1){file.read((char )&b,sizeof(b));if (!file) break;top++;book[top]=b;}file.close();} void clear() //全删} int addbook(int n,char na,char au, char n2, char da,char ti,int pr) //增加图书{Book p=search1(n);if (p==NULL){top++;book[top].addbook(n,na,au,n2,da,ti,pr);return 1;}return 0;} Book search1(int bookid) //查找图书{for (int i=0;iif (book[i].getnumber()==bookid &&book[i].gettag()==0)return &book[i];return NULL;} Book search2(int bookid,char name) //按书名查找图书{for(int i=0;iif(strcmp(book[i].getname(),name)==0){bookid=book[i].getnumber();return &book[i];}return NULL;}Book search3(int bookid,char author) //按主编查找图书{for(int i=0;iif(strcmp(book[i].getauthor(),author)==0){bookid=book[i].getnumber();return &book[i];}return NULL;}void bookdata(); //图书库维护void disp(){coutfor (int i=0;iif (book[i].gettag()==0)book[i].disp();}~BDatabase() //析构函数,将book[]写入book.txt文件中{fstream file("book.txt",ios::out);for (int i=0;iif (book[i].gettag()==0)file.write((char )&book[i],sizeof(book[i]));file.close();void BDatabase::bookdata(){int cho=1;int cho2=1;int cho3=1;int cho4;char bname[40];char editor[40];char banci[40];char ition[40];char year[40];int value;int bookid;Book b;while (cho!=0){coutcoutcoutcoutcoutcoutcoutcoutcoutcoutcoutcoutwhile(cho!=1&&cho!=2&&cho!=3&&cho!=4&&cho!=5&&cho!=6&&cho!=0){coutcout}switch (cho){case 1:cout cin >> bookid;cout cin >> bname;cout cin >>editor;cout cin>>banci;coutcoutcin>>year;coutcin>>value;coutcin>>cho4;while (cho4!=0&&cho4!=1){coutcin>>cho4;}switch (cho4){case 1:cho=1;break;case 0:cho=0;break;}bre{int sel;ak; case 3:cout cin >> bookid;b=search1(bookid);if }} (b==NULL){cout break;}b->delbook();break;case 4:coutcin>>cho3;switch(cho3){case 1:{cout cin >> bookid;b=search1(bookid);if (b==NULL){cout break;}b->disp();}break;case 2:{coutcin>>bname;b=search2(bookid,bname);if(b==NULL){coutbreak;}b->disp();}break;case 3:{coutcin>>editor;b=search3(bookid,editor);if(b==NULL){coutbreak;}b->disp();}break;}break;case 5:disp();break;case 6:clear();break;cout};int main(){BDatabase BookDB;coutcoutcoutcoutint w;cin>>w;if(w==0)BookDB.bookdata();("pause");return 0;}。

本文到这结束,希望上面文章对大家有所帮助。