文档库 最新最全的文档下载
当前位置:文档库 › 图书管理系统c语言程序设计

图书管理系统c语言程序设计

图书管理系统c语言程序设计
图书管理系统c语言程序设计

图书管理系统c语言程序设计

#include

#include//?????????????????

#include

#include

#include

using namespace std;

const int Maxr=100; //最多的读者

const int Maxb=100; //最多的图书

const int Maxbor=5; //每位读者最多借五本书class Reader{//读者类,实现对读者的信息的描述private:

int tag; //删除标记1:已删0:未删

int no; //读者编号

char name[10]; //读者姓名

int borbook[Maxbor]; //所借图书

public:

Reader(){

;

}

char *getname(){ //获取姓名

return name;

}

int gettag(){ //获取删除标记

return tag;

}

int getno(){ //获取读者编号

return no;

}

void setname(char na[]) { //设置姓名

strcpy(name,na);

}

void delbook() { //设置删除标记1:已删0:未删 tag=1;

}

void addreader(int n,char *na) { //增加读者 tag=0;

no=n;

strcpy(name,na);

for(int i=0;i

borbook[i]=0;

}

void borrowbook(int bookid){ //借书操作for(int i=0;i

if (borbook[i]==0) {

borbook[i]=bookid;

return;

}

}

}

int retbook(int bookid) { //还书操作

for(int i=0;i

if(borbook[i]==bookid) {

borbook[i]=0;

return 1;

}

}

return 0;

}

void disp(){ //读出读者信息

cout << setw(5) << no <

if(borbook[i]!=0)

cout << borbook[i] << "|";

cout << "]"<

}

};

class RDatabase{ //读者类库,实现建立读者的个人资料private:

int top; //读者记录指针

Reader read[Maxr]; //读者记录

public:

RDatabase(){ //构造函数,将reader.txt读到read[]中

Reader s;

top=-1;

fstream file("reader.txt",ios::in); //打开一个输入文件while (1) {

file.read((char *)&s,sizeof(s));

if (!file)break;

top++;

read[top]=s;

}

file.close(); //关闭reader.txt

}

void clear(){ //删除所有读者信息

top=-1;

}

int addreader(int n,char *na){ //添加读者时先查找是否存在

相关文档