In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to achieve a simple address book management system on C++". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Code # include # include using namespace std;// customize a contact node type typedef struct node1 {string name; / / name string tel; / / Mobile number string email; / / mailbox string address; / / address struct node1 * next; / / pointer to the next node} Node / / customize a binary sort tree node type typedef struct node2 {Node data; struct node2 * lchild, * rchild;} BSTNode;// to construct the node communication class class Fnode {public: Fnode (); / / constructor, which is used to initialize some variables ~ Fnode () / / destructor, which is used to clean the allocated memory after the end of the program void CreateInfo (); / enter contact information void InsertInfo (); / insert contact information void FindInfoName (); / / find contact information by name void FindInfoTel () / / find contact information by mobile phone number void DeleteInfoTel (); / delete contact information by mobile phone number void DispInfo (); / print all contact information void DispInfoSort (); / / output contact information by name void SaveInfoToFile () / / Save contact information to file void ReadInfoFromFile (); / / read contact information from file void Run (); / / function, including menu and related functions entry bool InsertBST (BSTNode * & bt, Node key); / / insert binary sort tree node to recursively implement void CreateBST () / / create a binary sort tree void InOrder (BSTNode * b) from the linked list; / / iterate through the output binary sort tree and recursively implement void DestroyBST (BSTNode * & b); / / release the binary sort tree and recursively implement private: bool opened / / used to indicate whether the file has been read, not read as 0, read as 1 Node * L, * p, * Q; / / define the header pointer of the address book node and the pointer BSTNode * btree; / / binary sort tree head node that may be used in other member functions}; / / constructor to initialize some variables Fnode::Fnode () {L = new Node; L-> next = NULL P = Q = NULL; btree = NULL; opened = 0;} / / destructor, which is used to clean the allocated memory after the end of the program Fnode::~Fnode () {p = L; while (p! = NULL) {delete p; p = p-> next;}} void Fnode::CreateInfo () / / create the node {int n; q = L, p = NULL While (Q-> next! = NULL) Q = Q-> next; cout > n; for (int I = 0; I
< n; i++) { p = new Node; cout >P-> tel > > p-> email > p-> address; p-> next = Q-> next; Q-> next = p; Q = p;}} / / insert contact information void Fnode::InsertInfo () {Q = L, p = NULL; while (Q-> next! = NULL) Q = Q-> next; p = new Node; cout p-> name > > p-> tel > > p-> email > > p-> address; p-> next = Q-next Q-> next = p; cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.