In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how C++ to achieve scenic spot tourism information management system, the article is very detailed, has a certain reference value, interested friends must read it!
The details are as follows
1 problem description
Nowadays, with the improvement of living standards, we all like to visit a tourist attraction during the holidays. in the scenic spot, we often hear tourists inquire about the shortest path and the shortest distance from one scenic spot to another. such tourists who do not like to visit according to the guide map often need a scenic spot management system to select their favorite tourist attractions, and then plan a shortest path and the shortest distance to visit. At the same time, save time and improve tourism efficiency.
2. Design of data structure
Establish a scenic spot tourism information management system to achieve the following functions:
1. Create a distribution map of scenic spots.
The distribution map of scenic spots is recorded through an adjacency matrix (essentially a two-dimensional array, m [I] [j] represents the weight from I to j, and zero means there is no direct path).
2. Output scenic spot distribution map (adjacency matrix)
Output the scenic spot distribution map by scanning the adjacency matrix
3. Output tour guide map: depth first strategy
First of all, by traversing the scenic spots and through an entrance scenic spot c given by the user, a guide route map is established, which is represented by a directed graph. Traversing adopts depth-first strategy (recursion), which is also the psychology of normal tourists.
4. Judge whether the tour guide map has a loop or not: topological sorting (finding scenic spots with penetration greater than 1)
In order to optimize the tour guide map, we can judge whether there is a loop in the map by topological sorting, and if there is a loop, print the scenic spots in the loop for manual optimization.
5. Find the shortest path and the shortest distance between two scenic spots: floyd algorithm
In the guided tour map, information services are also provided for tourists who do not want to follow the route, such as the shortest path and distance from one scenic spot to another. The shortest path and the shortest distance between any scenic spots will be output in this route map.
6. Output road construction roadmap: prime algorithm
In the construction of scenic spots, road construction is one of the important contents. Road construction must first ensure that all scenic spots can be connected, but at a minimum cost. This problem can be solved by finding the minimum spanning tree, and the minimum spanning tree can be obtained by prime algorithm.
Through the features added after modification:
7. Save the file name specified by the installation of the scenic spot distribution map (you can name the scenic spot) to the default directory file.
Here I encountered the problem of path format, which can be solved by querying the data.
8. Read the scenic spot distribution map with the specified file name from the default directory file.
This reduces the need to create a scenic spot distribution map every time, and it is also convenient to import the system from the existing scenic spot distribution map, which does not need to be built manually, and is more convenient and humanized in practical application.
9. Add scenic spot roads to the current scenic spot
At the beginning, the path of the scenic spot was not cleared to zero, so that after adding the scenic spot road, the scenic spot distribution map with fewer scenic spots was re-imported, and when adding the scenic spot road, it was found that the previous road still existed, so the road scenic spot should be cleared to zero before adding the scenic spot road.
3 algorithm design (core code) / / depth first search guide route int visited [M] = {0}; the number of scenic spots found by int np=0;// int p [M]; / / indicates the value of each scenic spot void DFS (int c) {/ / c is the scenic spot number np++;// is added every time it is recursively called to determine whether the last scenic spot is reached or not. If (np==S.count) {/ / arrived at the last scenic spot 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.