可按Ctrl+D收藏 蚂蚁资源网

蚂蚁资源网

图书管理系统流程图(流程图用什么软件做)

  • 全部评论(3)
  • 葬爱落雨
  • #include <iostream>#include <iomanip>#include <string>#include <fstream>//输入/输出文件流类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(){ tag=1; }//设置删除标记 1:已删 0:未删void addreader(int n,char *na)//增加读者{ tag=0; no=n; strcpy(name,na); for(int i=0;i<Maxbor;i++) borbook[i]=0;}void borrowbook(int bookid)//借书操作{ for(int i=0;i<Maxbor;i++) { if (borbook[i]==0) { borbook[i]=bookid; return; } } }int retbook(int bookid)//还书操作{ for(int i=0;i<Maxbor;i++) { if(borbook[i]==bookid) { borbook[i]=0; return 1; } } return 0;}void disp()//读出读者信息{ cout << setw(5) << no <<setw(10) << name<<"借书编号:["; for(int i=0;i<Maxbor;i++) if(borbook[i]!=0) cout << borbook[i] << "|"; cout << "]"<<endl; }};//读者类库,实现建立读者的个人资料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)//添加读者时先查找是否存在{ Reader *p=query(n); if (p==NULL) { top++; read[top].addreader(n,na); return 1; } return 0;}Reader *query(int readerid)//按编号查找{ for (int i=0;i<=top;i++) if (read[i].getno()==readerid && read[i].gettag()==0) { return &read[i]; } return NULL;}void disp() //输出所有读者信息{ for (int i=0;i<=top;i++) read[i].disp();}void readerdata();//读者库维护~RDatabase() //析构函数,将read[]写到reader.txt文件中{ fstream file("reader.txt",ios::out); for (int i=0;i<=top;i++) if (read[i].gettag()==0) file.write((char *)&read[i],sizeof(read[i])); file.close();}};void RDatabase::readerdata(){ char choice;char rname[20];int readerid;Reader *r;while (choice!='0'){ cout <<"\n\n\t\t\t读 者 维 护\n\n\n\t\t 1 新 增\n\n\t\t 2 更 改\n\n\t\t 3 删 除\n\n\t\t 4 查 找\n\n\t\t 5 显 示\n\n\t\t 6 全 删\n\n\t\t 0 退 出"<<endl; cin >> choice; switch (choice) { case '1': cout << "输入读者编号:"; cin >> readerid; cout << "输入读者姓名:"; cin >> rname; addreader (readerid,rname); break; case '2': cout << "输入读者编号:"; cin >> readerid; r=query(readerid); if (r==NULL) { cout << " 该读者不存在 "<<endl; break; } cout << "输入新的姓名:"; cin >> rname; r->setname(rname); break; case '3': cout << " 输入读者编号:"; cin >> readerid; r=query(readerid); if (r==NULL) { cout <<" 该读者不存在" << endl; break; } r->delbook(); break; case '4': cout << "读入读者编号:"; cin >> readerid; r=query(readerid); if (r==NULL) { cout <<"该读者不存在"<< endl; break; } r->disp(); break; case '5': disp(); break; case '6': clear(); break; default:cout<<"输入错误,请从新输入:";break; }}}//图书类,实现对图书的描述,图书的编号,书名,借出,还入等class Book{private: int tag;//删除标记 1:已删 0:未删int no;//图书编号char name[20];//书名int onshelf;//是否再架 1:再架 2:已借public:Book(){}char *getname() { return name; }//获取姓名int getno(){ return no; }//获取图书编号int gettag(){ return tag; }//获取删除标记void setname(char na[])//设置书名{ strcpy(name,na);}void delbook(){ tag=1;}//删除图书void addbook(int n,char *na)//增加图书{ tag=0; no=n; strcpy(name,na); onshelf=1;}int borrowbook()//借书操作{ if (onshelf==1) { onshelf=0; return 1; } return 0;}void retbook()//还书操作{ onshelf=1;}void disp()//输出图书{ cout << setw(6) << no << setw(18) << name << setw(10) <<(onshelf==1? "在架":"已借") <<endl;}};//图书库类,实现对图书的维护,查找,删除等class BDatabase{private: 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()//全删{ top=-1;} int addbook(int n,char *na)//增加图书{ Book *p=query(n); if (NULL==p) { top++; book[top].addbook(n,na); return 1; } return 0;}Book *query(int bookid)//查找图书{ for (int i=0;i<=top;i++) if (book[i].getno()==bookid &&book[i].gettag()==0) { return &book[i]; } return NULL;}void bookdata();//图书库维护void disp(){ for (int i=0;i<=top;i++) if (book[i].gettag()==0) book[i].disp();}~BDatabase()//析构函数,将book[]写到book.txt文件中{ fstream file("book.txt",ios::out); for (int i=0;i<=top;i++) if (book[i].gettag()==0) file.write((char *)&book[i],sizeof(book[i])); file.close();}};void BDatabase::bookdata(){ char choice;char bname[40];int bookid;Book *b;while (choice!='0'){ cout <<"\n\n\n\t\t\t图 书 维 护 "<<endl<<endl; cout<<"\t\t1 新 增\n \t\t2 更 改\n\t\t3 删 除\n\t\t4 查 找\n\t\t5 显 示\n\t\t6 全 删\n\t\t0 退 出"<<endl; cin >> choice; switch (choice) { case '1': cout << "输入图书编号:"<<endl; cin >> bookid; cout << "输入图书书名:"<<endl; cin >> bname; addbook(bookid,bname); break; case '2': cout << "输入图书编号:"<<endl; cin >> bookid; b=query(bookid); if (b==NULL) { cout << " 该图书不存在 "<<endl; break; } cout << "输入新的书名:"<<endl; cin >> bname; b->setname(bname); break; case '3': cout <<" 读入图书编号:"<<endl; cin >> bookid; b=query(bookid); if (b==NULL) { cout <<" 该图书不存在" << endl; break; } b->delbook(); break; case '4': cout << " 读入图书编号:"<<endl; cin >> bookid; b=query(bookid); if (b==NULL) { cout <<" 该图书不存在"<< endl; break; } b->disp(); break; case '5': disp(); break; case '6': clear(); break; default:cout<<"输入错误,请从新输入:"; }}}//main() 函数的实现,程序的主界面的引导void main(){ char choice;int bookid,readerid;RDatabase ReaderDB;Reader *r;BDatabase BookDB;Book *b;while(choice!='0'){ cout <<endl<<endl<<"\t\t\t 图 书 管 理 系 统\n\n\n"; cout <<"\t\t\t1 借 书\n\n\t\t\t2 还 书 \n\n\t\t\t3 图 书 维 护\n\n\t\t\t4 读 者 维 护\n\n\t\t\t0 离 开"<<endl; cin >> choice; switch (choice) { case '1': cout <<" 借书 读者编号:"; cin >>readerid; cout <<" 图书编号: "; cin >>bookid; r=ReaderDB.query(readerid);//按编号查找 if (NULL==r) { cout <<" 不存在该读者,不能借书"<< endl; break; } b=BookDB.query(bookid); if (b==NULL) { cout <<" 不存在该图书,不能借书"<< endl; break; } if (b->borrowbook()==0) { cout << " 该图书已借出,不能借书"<< endl; break; } r->borrowbook(b->getno()); break; case '2': cout<<"还书\n 读者编号:"; cin >>readerid; cout << " 图书编号:"; cin >>bookid; r=ReaderDB.query(readerid); if (r==NULL) { cout <<" 不存在该读者,不能还书" << endl; break; } b=BookDB.query(bookid); if (b==NULL) { cout <<" 不存在该图书,不能还书" <<endl; break; } b->retbook(); r->retbook(b->getno()); break; case '3': BookDB.bookdata(); break; case '4': ReaderDB.readerdata(); break; default:cout<<"输入错误,请从新输入:"; }}}
  • 2021-12-28 12:13:18
  • 远古
  • 我们也开始做一个课程设计~~~这是我的同学做:#include&lt;stdio.h&gt;#include&lt;stdlib.h&gt;#include&lt;cono.h&gt;Struct Book {int ID,USR [10],总,商店,天[10];Char名称[31],作者[21];}书[100];/ *以上是结构的定义,用于存储书籍和借贷。* / void page_title(char * menu_item){clrs(&gt; g书籍天气 - %s - &QUOT;,MENU_ITEM);以上是打印标题的函数,当前状态可以由参数menu_item显示。* / void return_confirm(void){printf(“按任意键返回...”);getch();} / *以上是返回先前请求确认的函数,以便在返回结果* / int search_book(void){int n,i;Printf(&QUOT;请输入书名:&率);Scanf(“%d”,&amp; i);for(n \u003d 0; n&lt;100;n ++){if(书籍[n] .id \u003d\u003d i){printf(“标题:%s&&符号”,书籍[n] .name);printf(“作者:%s”;书籍[n]。author; printf(“折旧:%d的”书籍[n] .store; printf(&&ic); printf(“%d”,书籍[n]。总计;返回n;}}} printf(“输入错误或无效的书名。”); return-1;} / *上面的函数是阵列中匹配的书号的记录,显示信息并返回对数下标。如果找不到相应的记录,则错误不正确并返回为-1。* / void book_out(void){int n,s,l,d; page_title(&QUOT;借书“);如果((n \u003d search_book())!\u003d - 1&amp;&amp;书籍[n] .store&gt; 0){printf(&QUOT;请输入招标证书编号:&QUOT;); SCANF(“%d”,&amp; s); printf(&QUOT;请输入NU借款人的MBER:“);Scanf(“%d”,&amp; d);for(l \u003d 0; l&lt; 10; l ++){i(书籍[n] .usr [] \u003d\u003d 0){书[n] .usr [l] \u003d s;书籍[n]。日[l] \u003d d;break;}}书[n] .store--;}如果(n!\u003d - 1&amp;&amp;书籍[n] .store \u003d\u003d 0)printf(&QUOT;本书已被借用。;);return_confirm();} / *以上是借用书的功能,首先致电书籍功能* / void book_in(void){int n,s,l;page_title(“退回书”);if(n \u003d search_book())!\u003d - 1&amp;&amp;书籍[n] .store&lt;书籍[n] .total){printf(“借款人书籍证书列表:”);对于(L \u003d 0; L&lt; 10; l ++)(书籍[n] .usr [l]!\u003d 0)printf(“[%d] - %d日),书籍[n] .usr [l],书籍[n]。日[l]);Printf(&Quot;请输入竞标号:&率);Scanf(“%d”,&amp);for(l \u003d 0; l&lt; 10; l ++){if(书籍[n] .usr [l] \u003d\u003d s){书[n] .usr [l] \u003d 0;书籍[n]。日[l] \u003d 0;break;}}书[n] .store ++;}如果(n!\u003d - 1&amp;&amp;书籍[n] .store \u003d\u003d books .total)printf(“全部”)。“);return_confirm(); void book_add(void){int n;page_title(“注册新书”);for(n \u003d 0; n&lt; 100; n ++)(书籍[n] .id \u003d\u003d 0)中断;printf(“序列号:”);Scanf(“%d”);&amp;书籍[n]。地);printf(“书籍名称:”);Scanf(“%s”,&amp;书籍[n] .name);printf(“);Scanf(“%s”,&amp;书籍[n] .Author);printf(“数量:”);Scanf(“%d”,&amp;书籍[n] .total);书[n]。商店\u003d书籍[n] .total;requiredfirm(); void book_del(空白){int n;page_title(“注销旧书”);if((n \u003d search_book())!\u003d - 1)书籍[n] .id \u003d 0;printf(&QUOT;本书已退出。&QUOT;);return_confirm(); void main(void){菜单:page_title(“运算符菜单”);printf(&QUOT;请使用数字键选择操作“);printf(「1借款借款书2返回书籍「);printf(“3注册新的Book4 Logout旧书”);printf(“0出口”);switch()){case'1':book_out();休息;案例'2':Book_in();休息;案例'3':Book_add();休息;案例'4':book_del();案例'0':退出(0);} goto菜单;} {int n;page_title(&QUOTINGY?症状“);if((n \u003d search_book())!\u003d - 1)书籍[n] .id \u003d 0;printf(&QUOT;广?);return_confirm();} void main(void){菜单:page_title(“佥佥”);printf(“萩萩方向忖夲”);printf(“12次复制”);printf(&QUOT; 3宽下降宽?症状“);printf(“0竃”);switch()){case'1':book_out();休息;案例'2':Book_in();休息;案例'3':Book_add();休息;案例'4':book_del();休息;案例'0':退出(0);}转到菜单;
  • 2021-12-28 12:11:37
  • 葬爱落雨
  • 图书管理系统C语言aa,我可以给你个学生管理系统的,你自己对着改改吧。 #include "stdio.h" #include "string.h" #define N 2 struct student { long num; char name[20]; char sex; int chinese; int math; int english; }; struct student stu[N]; int n; int choose; void fun1(); void fun2(); void fun3(); void fun4(); void fun1() { int i; for(i=0;i
  • 2021-12-28 12:11:37
  • 商品推荐