#include <iostream>
#include <malloc.h>
using namespace std;
typedef struct book {
char no[8]; //8位书号
char name[20]; //书名
double price; //价格
}book;
typedef struct lnode {
book data; //数据域
struct lnode* next; //指针域
}lnode;
bool iscontain(string str1, string str2) {
if (str1.find(str2) != string::npos) {
return true;
}
else {
return false;
}
}
class linklist {
private:
lnode* first;
public:
linklist() {
first = new lnode;
first->next = NULL;
}//无参构造函数,只构建有头指针的空链表
void insert(book b) {
lnode* p;
p = first;
while (p->next != NULL) {
p = p->next;
}
lnode* s = new lnode;
s->data = b;
s->next = p->next;
p->next = s;
}
void print() {
lnode* p;
p = first->next;
while (p != NULL) {
cout << p->data.no << " " << p->data.name << " " << p->data.price << endl;
p = p->next;
}
}//输出操作
void insertone() { //新图书插入到图书表指定的位置
book book;
int n;
cout << "请输入插入的位置:";
cin >> n;
lnode* p;
p = first; int count = 0;
while (p != NULL && count < n - 1) {
p = p->next;
count++;
}
if (p == NULL) {
cout << "输入的位置不当,结束本次操作" << endl;
}
else {
cout << "输入图书信息:";
cin >> book.no >> book.name >> book.pric
图书管理系统(源代码)
最新推荐文章于 2024-05-25 14:39:53 发布