Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement a simple address Book Management system on C++

2025-02-25 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report