学无先后,达者为师

网站首页 编程语言 正文

C++实现图书管理系统源码_C 语言

作者:往事五块两毛一   更新时间: 2022-05-16 编程语言

本文实例为大家分享了C++实现图书管理系统的具体代码,供大家参考,具体内容如下

直接上代码

#include 

#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

class Books
{
    private:
        string bookname; //书名 
        string writername;  //作者名
        string publishname;  //出版社
        int num;  //图书数量        
        string sname; // 学生姓名 
        int number; // 学生账号 
        static int length; //静态数据成员 
        int zf;  //借阅图书数量 
    public:
        Books(string b="1",string w="2",string p="3",int n=0,int f=0);    //声明构造函数    
        void maintain(Books *m); // 信息的增删改
        void demand(Books *m); // 信息查询
        void bore(Books *m); //图书的借,还
        void stat(Books *m); //信息统计和显示
        void jssc();  // 输出格式函数 
        void sc(Books *p); //输出格式函数 
        void rest(Books *m); //统计图书受欢迎程度
        void storage(Books *m); //信息保存
        void OpenFile(); //打开文件 
        void quit(); //退出系统    
};

int Books::length=5;

Books::Books(string b,string w,string p,int n,int f)//定义构造函数 
{
    bookname=b;
    writername=w;
    publishname=p;
    num=n;
    zf=f;
}

void Books::maintain(Books *m)//图书的增删改 
{
    int i=0;
    int j;
    m[i].sc(m);
    
    B:cout<<"添加图书请按1,删除图书请按2,修改图书信息请按3,退出请按0"<>a;        
    
    if(a==1)  //添加图书 
    {        
        A:cout<<"请依次输入书名,作者,出版社,图书数量"<>(*(m+length)).bookname>>(*(m+length)).writername>>(*(m+length)).publishname>>(*(m+length)).num;
        length++;
        
        cout<<"继续添加请按1,执行其他操作请按2"<>b;
        if(b==1)
          goto A;
        else
          goto B;        
    }
    
    if(a==2)    //删除图书 
    {
        C:cout<<"请输入要删除的书名" <>a;
        i=0;
        
        while(i>c;
        if(c==1)
          goto C;
        else
          goto B;
    } 
    
    if(a==3)   //修改图书信息 
    {
        D:cout<<"请输入要修改的书名" <>b;
        i=0;
        
        while(i>m[i].bookname>>m[i].writername>>m[i].publishname>>m[i].num;    
       
        cout<<"继续修改请按1,执行其他操作请按2"<>d;
        if(d==1)
          goto D;
        else
          goto B;
    } 
    
    if(a==0)
    {
        goto E;    
    }
    E:;
}

void Books::demand(Books *m)//查找图书 
{
    cout<<"请输入要查找的书名" <>b;
    int i=0;
        
    while(i>d;
    if(d==1)
      goto F;
    else
      goto G;
    G:;
} 

void Books::bore(Books *m)   //借书还书 
{
    int i;
    A:cout<<"借书请按1,还书请按2,退出请按0:"<>t;
    
    if(t==1)
    { 
        B:cout<<"请输入要借的书名和数量:" <>a;
        cin>>s; 
        int i=0;
        while(i=0)
            {
                m[i].num=m[i].num-s;
                cout<<"请输入借书人姓名及学号:" <>b;
                cin>>c;
                m[i].sname=b;
                m[i].number=c;
                m[i].zf=s;
            }
            else
            {   
                cout<<"图书数量不够"<>g;
        if(g==1)
            goto B;
        else
          goto A;
    }
    
     if(t==2)
    {
        C:cout<<"请输入要还的书名和数量:" <>d;
        cin>>e; 
        i=0;
        while(i>f;
        if(f==1)
          goto C;
        else
          goto A; 
    }
    
    if(t==0)
    {
        goto E;    
    }
    E:;
} 

void Books::stat(Books *m)
{
    int i=0;
    int n=0;
    int fsum=0;//被借阅数量 
    int sum=0;//剩余书籍总数量
    for(i=0;i>t;
    if(t==1)
    {
        
    AAA:cout<<"输入账号名:";
        cin>>sber; 
        elem[i]=sber;
        for(v=0;v>t;
        if(t==1) 
        {
            system("cls");
            goto AAA;
          }
        else
        {
              system("cls");
        }    
    }  
    
    cout<<"执行登录请按2,退出请按3:";  //登录 
    cin>>t;
    if(t==2) 
    {        
        cout<<"输入账号:";
        cin>>s2;
        for(j=0;j<=i;j++)
        {
             if(elem[j]==s2) 
             {
                 k=j; //k为位序 
                   goto BBB;
             }
        }
        cout<<"账号不存在,退出!";
         exit(0);
     
    BBB:cout<<"输入密码:"; 
        for(x=0;x<3;x++) 
        {
            h=0;
              while(h<10&&(c[h]=getch())!='\r') 
            {
                   d[h]=c[h];
                  h++;
                  cout<<"*";
            }
            s1=d;      //字符数组赋值给字符串 
            if(s[k]==s1) 
            {
                  cout<<"登陆成功";
                  x=x-1;
                break;
            }
            else
            {
                  cout<>z;
    switch(z)
    {
      case 1: book[0].maintain(m); break;
      case 2: book[0].demand(m); break;
      case 3: book[0].bore(m); break;
      case 4: book[0].stat(m); break;
      case 5: book[0].rest(m); break; 
      case 6: book[0].storage(m);break;
      case 7: book[0].OpenFile();break;
      case 8: exit(1);break;
    } 
    cout<<"继续请按y或Y:";
    cin>>ch;    
    }
    return 0;
}

运行截图

原文链接:https://blog.csdn.net/qq_43641475/article/details/103576677

栏目分类
最近更新