2019 Northern personal training program

 

First, project ideas

This project implements a command-line program to help subway travel route planning, usually when referring to the actual travel situation, consider the transfer, the waiting time and other costs, while the shortest path subway lines, but also by the minimum transfer times to be implemented. Due to limited capacity, if the program imperfections, enjoy understanding teacher.

  1. Subway line information using a text file named subway.txt storage, file content and format are as follows:

Line1: Liu Yuan, West Cross embankment, Winery, Benxi Road, thrifty Road, Lake in West Point # 6, northwest, southwest corner # 2, Second Latitude, Haiguangsi, Anshan Road, Yingkou Road # 3, White floor, tile-roofed house at # 5, South building, Tucheng, Chentangzhuang, Fuxingmennei, Huashan, the University of Finance and Economics, double-Lin, Li floor
Line2: Cao, Bian Xing, mustard Park West Road, Xianyang Road, Changhong Park # 6, wide open four road southwest corner # 1, the Drum tower, the southeast corner, the founding of the road, Tianjin Railway station # 3, # 9, ocean international Center, Sunco bridge, Jingjiang Road # 5, Fuxin Tsui village, Lantau East Side, pe Road, State Hill Road, Airport economic zone, Binhai international Airport
Line3: small lake, high yield River, North China Group, Tasly, yixingbu, Zhangxingzhuang # 5, Rail Road, North station # 6, Zhongshan Road, Lion bridge, Tianjin Railway station # 2, # 9, Jin Wan Plaza, Heping Road, Yingkou Road # 1, Xikang, Wujiayao, sky tower, Zhou Deng Memorial Hall, Hongqi Road # 6, Wangdingdi, Huayuan, University City, High-tech zone, universities industrial zone, Yang Wu Zhuang, South station
Line5: Beichen Science and Technology Park North, Dan Hebei Road, Beichen Road, Vocational University, the Huaihe River Road, Liaoning, Hebei Road, Yixing North, Zhangxingzhuang # 3, Zhicheng road, Siyuan Road, Jianchang Road, Admiralty River Bridge # 6, Yueyahe, happy park, Jingjiang Road # 2, forest Road, Jintang Road, Zhigu # 9, # 1 under the tile-roofed house, southwest building, cultural Center # 6, # 6 hotels in Tianjin tumor hospital # 6, sports centers, Lingbin Road, Chang Ling Road, First Affiliated hospital of Traditional Chinese Medicine, Lee seven Jhuangnan
Line6: Southern Sun Zhuang, South Ho Chong, dabizhuang Admiralty Street, Xu Chuang Tzu, Admiralty River Bridge # 5, civil rights doors, Beining Park, North station # 3, Xinkaihe, outside the hospital affiliated to Tiantai Road, North Canal, the North bamboo, West station # 1, Fuxing Road, people hospital, Changhong Park # 2, Yibin Road, Anshan Road West, Tiantuo, a central hospital, Hongqi Road # 3, the wind Road, South Ping, water Park Road, cancer hospital, # 5, # 5 hotels in Tianjin, cultural center # 5, Paradise Road, Eagle's Nest Road, Black Bull City Road, Meijiang Road, left River Road, Mei Jianggong Park, Meijiang convention and Exhibition Center, the liberation of South Road, Dongting Road, Meilin Road
Line9: Tianjin Railway station # 2, # 3, Dawangzhuang, ten once the road, selling until # 5, Dongxing Road, Zhongshan gate, One bridge, Second bridge, zhangguizhuang, the new legislation, DEDA, Xiaodong Zhuang, Junliangcheng, steel companies, Hu homes, Tanggu, TEDA, Civic Plaza, Lake Road, the Convention Center, the East China Sea Road

After the line with the name ":" its site after an interval, and inter-site by site "," interval;
if a transfer station or a secondary station, thereafter with the "# number", this denotes the site of this line the serial number can be referred to the transfer line, such as line 1 to the West station may line 6, line 9 Tianjin station may go to line 2 and line 3.
2. The use of C ++, specific ideas include:

Mian () receives a user's input, calling each function block, the shortest path.

Station () function, to realize each line read site name, and put it in the array, the array can be labeled using site having a transfer qualities.

Using the BFS algorithm, specify the source - the shortest path to the end point of the search. .BFS algorithm uses a queue to achieve a hierarchical graph traversal. In traverse the level, the record path and the shortest path.

The Path () function, generating and selecting paths to achieve.
test:

1, test the correctness of the reading of each line of text TXT

2, the test array is read correctly transfer station

3, the test route selection function, whether the first output, the second output is the shortest path

  • Experience:
  • 1, for years the project program, a lot of strange, you need to write a written code

Guess you like

Origin www.cnblogs.com/zhanggreenwind/p/11225214.html