#include <iostream>; #include<string>; using namespace std; typedef string ElemType; #define TRUE 1; #define FALSE 0; #define OK 1; #define ERROR 0; #define OVERFLOW -1; #define MAXSIZE 999999; typedef int Status; typedef struct Book { string bookID; //书号 string bookName; //书名 string writerName; //作者 int booknumnow; //现库存量 string biglei; //大类 string smalllei; //小类 }Book, * Bookk; //书本类型 typedef struct LNode //链表 { Book* book; struct LNode* next; }LNode, * LinkList; typedef struct FiveTNode//每一层有五类 { ElemType data; struct FiveTNode* child1, * child2, * child3, * child4, * child5; LNode* lnode; }FiveTNode, * FiveTree; void CreateFiveTree(FiveTree& T, FiveTree& A, FiveTree& B, FiveTree& C, FiveTree& D, FiveTree& E)//创建树 { T = new FiveTNode;//生成根结点 T->data = "图书"; T->child5 = new FiveTNode; FiveTree E = T->child5; E->data = "综合类书籍"; E->child5 = new FiveTNode; E->child5->data = "安全科学"; E->child5->lnode = new LNode; E->child5->lnode->book = new Book; E->child5->lnode->book->bookName = "《安全科学你我需知》"; E->child5->lnode->book->bookID = "25"; E->child5->lnode->book->writerName = "刘俊"; E->child5->lnode->book->booknumnow = 58; E->child5->lnode->next = NULL; //cout << A->child1->lnode->book->bookName; //cout << E->child5->lnode->book->bookID; } int main() { string book_update_ID_new, book_update_ID; cin >> book_update_ID; cin >> book_update_ID_new; FiveTree T, A, B, C, D, E; CreateFiveTree(T, A, B, C, D, E); LinkList s = new LNode; LinkList q, t; LinkList pe5 = E->child5->lnode; s->book->bookID = book_update_ID_new; s->next = pe5->next; pe5->next = s; q = E->child5->lnode; while (q && q->book->bookID != book_update_ID) { q = q->next; } q = q->next; t = q->next; q->next = t->next; delete t; cout << s->book->bookID << " " << s->book->bookName << " " << s->book->writerName << endl; cout << " ***************************************" << endl; return 0; }
时间: 2024-04-05 18:35:50 浏览: 122
#include <iostream>
这是一段 C++ 代码,主要实现了一个基于五叉树结构的图书管理系统。其中包括书本类型的定义、链表结构定义、以及五叉树结构的定义和创建。主要功能是实现图书的添加、删除和修改操作。具体来说,是通过输入图书的 ID 号,找到对应的图书节点,并且修改其中的信息,比如库存量、书名等。同时,还可以在五叉树结构中查找图书,以及实现图书的分类管理。
阅读全文