Campus tour Guide (application of the chart)
[problem description]
Design a campus guide program for visitors to provide a variety of information inquiries services.
(1) Design School's campus floor plan, contains not less than 10 attractions, in order to show the points in the school attractions, storage attractions name, code, introduction and other information; to indicate the path, the length of the path and other relevant information;
(2) Provide the basic information modification function;
(3) To provide visitors with information about any of the attractions in the map;
(4) To provide visitors with the tourist attractions inquiry, that is known as a scenic spot, to find a spot between the shortest path and length.
analysis : Floyd algorithm to find the shortest path, and save the path.
Source:
#include <iostream> #include <stdio.h> #include <string> #include <string.h> #include < cstring> #include <stack> #include <queue> #include <algorithm> #include <math.h> #include
<vector> #include <iomanip> #include <map> using namespace std;
#define MX 9999999 const int N = 11;
int path[n][n], d[n];
struct node {int Daihao;
String name;
String Jianjie;
}S1,S2; Node add[n]= {1, "The teaching building of the International Institute of Education", "this building is an exclusive teaching building for the Institute of International Education in China, working with foreign countries." At the same time, built-in postgraduate study room, provides a good learning atmosphere. "}, {2," Bei Yuan basketball court "," it is one of the venues for students ' leisure activities in Beiyuan, but also has volleyball and tennis courts outside the basketball court, but because of its low lying, it is also called "Peking University Pit". "}, {3," Bei Yuan Restaurant "," North Garden Restaurant has a total of three floors, providing food from all over the country, reasonable price, food tube full, to meet the needs of the vast number of teachers and students. " "}, {4," University Student Activity Center "," The activity center has five levels, has the table tennis, the basketball, the badminton and so on the ground, facilitates the leisure, at the same time is also the important ceremony holds the place, can accommodate tens of thousands of people, majestic magnificent. " "}, {5," center Playground "," center playground with plastic runway and open-air tennis court, often students come to this morning exercise, in addition to the anniversary of the major events such as the event also carried out in this, with a "central playground" reputation. "}, {6," library "," the library has a variety of professional books, is a veritable "book of the Sea", provides a wealth of learning resources, is also the most magnificent building, not one. "}, {7," Crape Myrtle Square "," Crape Myrtle Square is a community activities and job fairs held at the point, whenever the festival, Crape Myrtle Square must be lively and extraordinary, is the major community activities venues. " "}, {8," The Teaching complex "," it gathers the 8,9,10,11 building, is the office place of the major colleges, the sameIt is also the place where the labs converge and the academic atmosphere is strong. "}, {9," Nanyuan playground "," Nanyuan playground for the students to live in the place of the activities of Nanyuan, at the same time equipped with exercise equipment and basketball court, greatly facilitate the life of the students. " "}, {10," Nanyuan restaurant "," Nanyuan restaurant has a total of three floors, beautiful environment, delicious food, to meet the majority of teachers and students, and reasonable prices. " "}, {11," Industrial training base "," the base is located in the south of the Ministry of Industry, providing major machine tools for students to practice, is the perfect place for students to practise training. "
" }
}; int W[n][n] = {{0, ten, ten, +, +, mx, mx, mx, mx, mx, mx}, {ten, 0,, mx, mx, mx, mx, mx, mx, mx}, {10, 15, 0 , MX, 2, mx, mx, mx, mx, mx, mx, {0, mx, mx/mx, mx, mx, mx, MX, 2, 0, MX, mx, mx, mx, MX, MX}, {mx, mx, mx, mx, 0, +, +, mx, mx, mx}, {mx, mx, mx, mx, mx, 0, mx}, MX, mx, mx}, {mx, mx, mx, mx, MX, +, 0, 0, (+), (+), {mx, mx, mx, mx, mx, mx, mx,, 0, mx, mx, mx, mx, mx, MX,,.
X, MX, mx, mx, mx, mx, MX, 40, 20, 15, 0}};
void Floyd () {//floyd algorithm core code for (Int. i=0;i<n;i++) for (int j=0;j<n;j++) path[i][j]=j;
for (int k=0;k<n;k++) for (int i=0;i<n;i++) for (int j=0;j<n;j++) if (W[i][j]>w[i][k]+w[k][j]) {
W[I][J]=W[I][K]+W[K][J]; Path[i][J]=path[i][k];
}} void Path (int st,int ed) {int x=st;
cout<< "Path:" <<add[x].name;
while (x!=ed) {cout<< "--" <<add[path[x][ed]].name;
X=path[x][ed];
} cout<<endl;
} void ShortPath () {int st,ed;
cout<< "Please enter a starting point and destination (1~11 spaces):" <<endl;
cin>>st>>ed; if (st>=1&&st<=11&&ed>=1&&ed<=11) {cout<< "from" <<add[st-1].name<
< "to" <<add[ed-1].name<< ":" <<endl;
Floyd ();
Path (st-1,ed-1); cout<< "path length:" <<w[st-1][ed-1]*10<< "M.
"<<endl<<endl; The Where else {cout<< "input does not exist.
"<<endl;
}} void Find () {int n_id;
cout<< "Please enter the name of the attraction to be queried" <<endl;
cin>>n_id; if (n_id>=1&&n_id<=11) {cout<< "code:" "<<add[n_id-1].daihao<<" "" <<endl < < "name:" <<add[n_id-1].name<<endl << "Introduction:" <<add[n_id-1].jianjie<<endl << "query succeeded. = ^_^ = "<<endL } else {cout<< "entered incorrectly ...
"<<endl;
}} void Xiugai () {string mi;
int St,ed,len;
cout<< "Please enter the Administrator password";
cin>>mi;
if (mi== "123456") {cout<< "Please enter the location number (1~11 spaces) where you want to modify the location of the route:";
cin>>st>>ed;
cout<< "Please enter path length";cin>>len;
W[st-1][ed-1]=w[ed-1][st-1]=len; } else {cout<< "Sorry, password is incorrect.
^_^ "<<endl;
}} void Exit () {cout<<endl;
cout<< "--------------------------------" <<endl;
cout<<endl;
cout<< "◇ Thank you for using = ^_^ =◇" <<endl;
cout<<endl;
cout<< "--------------------------------" <<endl;
cout<<endl;
} void MP () {cout << Endl;
cout << "★---------★---------★---------★---------★---------★---------★" << Endl;
cout << "1" International Education Institute teaching Building "<< Endl; cout << "☆| ☆ "<< Endl;
cout << "2" Beiyuan basketball court <-----------|--------------------> "3" Bei Yuan restaurant << Endl; cout << "☆|
☆ "<< Endl; cout << "|
"<< Endl;
cout << "☆" 4 "Student Activity Center <-----" 5 "center Playground ☆" << Endl; cout << "|
"<< Endl; cout << "☆ North |
☆ "<< Endl; cout << "|
"6" library "<< Endl; cout << "☆ West---|---East |
☆ "<< Endl; cout << "|
|--------------------> "7" crape Myrtle Plaza "<< Endl; cout << "☆ South | ☆ "<< Endl;
cout << "" 8 "Teaching buildings" << Endl; cout << "☆|
☆ "<< Endl;
cout << "9" Nanyuan Playground <-------------|-------------------"10" Nanyuan restaurant << Endl; cout << "☆|
☆ "<< Endl;
cout << "" 11 "Industrial training base" << Endl;
cout << "★---------★---------★---------★---------★---------★---------★" << Endl;
cout<<endl;
} void Menu () {cout<<endl;
cout<< "--------------------------------" <<endl;
cout<< "Campus Guide System" <<endl;
cout<< "◇◇" <<endl; cout<< "1, Chinese workers Guide map" <<Endl
cout<< "◇ 2, Attractions Information Inquiry (guest) ◇" <<endl;
cout<< "3, the way of sightseeing (guests)" <<endl;
cout<< "◇ 4, Guide map information modification (Admin) ◇" <<endl;
cout<< "5, exit System" <<endl;
cout<< "◇◇" <<endl;
cout<< "Welcome to Chinese teachers and students" <<endl;
cout<< "--------------------------------" <<endl;
cout<<endl<<endl<< "Please select function:";
} int main () {System ("color 37");
int n;
while (1) {System ("CLS");
menu ();
cin>>n;
if (n==1) {System ("CLS");
MP ();
System ("pause");
} else if (n==2) {System ("CLS");
MP ();
Find ();
System ("pause");
} else if (n==3) {System ("CLS");
MP ();
ShortPath ();
System ("pause");
} else if (n==4) {System ("CLS");
MP ();
Xiugai ();
System ("pause"); } else IF (n==5) {System ("CLS");
Exit ();
Break } else {cout<< "input is incorrect, please re-enter.
"<<endl;
System ("pause");
Continue
}} return 0; }