You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
1.5 KiB
87 lines
1.5 KiB
#include<iostream>
|
|
#include<fstream>
|
|
#include<string>
|
|
#include"book.h"
|
|
#include"library.h"
|
|
using std::cout;
|
|
using std::cin;
|
|
using std::endl;
|
|
extern Book booklist[50];
|
|
extern int num;
|
|
const char pass[10] = { "123456" };
|
|
void wxy::guanli()
|
|
{
|
|
void daochu();
|
|
char ch;
|
|
char password[20];
|
|
int i{};
|
|
for (; i < 3; i++)
|
|
{
|
|
cin.get(ch);
|
|
cout << "input password" << endl;
|
|
cin.get(password, 20);
|
|
cin.clear();
|
|
if (strcmp(password, pass) == 0)
|
|
{
|
|
break;
|
|
}
|
|
cout << "wrong password,try again" << endl;
|
|
}
|
|
cin.get(ch);
|
|
if (i >= 3)
|
|
{
|
|
for (;;)
|
|
{
|
|
cout << "sorry,you don't have the permission,press enter to quit" << endl;
|
|
cin.get(ch);
|
|
if (ch == '\n')
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
for (;;)
|
|
{
|
|
int g{1};
|
|
int xv;
|
|
cout << "input the book's name auther and amount" << endl;
|
|
char name[80];
|
|
char auther[80];
|
|
int amount;
|
|
cin.getline(name, ' ');
|
|
cin.clear();
|
|
cin.getline(auther, ' ');
|
|
cin.clear();
|
|
cin >> amount;
|
|
for (int i{}; i < num; i++) {
|
|
if (strcmp(name, booklist[i].Name) == 0) {
|
|
g = 0;
|
|
xv = i;
|
|
break;
|
|
}
|
|
}
|
|
if (g)
|
|
{
|
|
strcpy_s(booklist[num].Name, name);
|
|
strcpy_s(booklist[num].Auther, auther);
|
|
booklist[num].amount = amount;
|
|
num++;
|
|
daochu();
|
|
}
|
|
else
|
|
{
|
|
booklist[xv].amount += amount;
|
|
daochu();
|
|
}
|
|
cout << "wanna go on? press n to quit,press enter to continue" << endl;
|
|
cin.get(ch);
|
|
cin.get(ch);
|
|
if (ch == 'n' || ch == 'N')
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
} |