点击这里进入我的资源下载
1. 简单介绍
#include#include #include using namespace std; #define Num 17 #define Maxedge 32760 typedef struct { char name[10]; int number; char introduce[100]; } vertex; vertex constructions[Num]; int edge[Num][Num]; int shortest[Num][Num]; int path[Num][Num]; int myMap() { printf("tt河北科技大学新校区平面图(括号内为相对应的数字编号)nn"); printf(" 西北操场(1)———————校医院(2)——————文法学院(3)——————风雨操场(4) n"); printf(" | | | | n"); printf(" | | | | n"); printf(" 西门(5)—————————牧星湖(6)————————公教楼(7)————————主体育场(8) n"); printf(" | | | | n"); printf(" | | | | n"); printf(" 第三餐厅(9)—————————图书馆(10)—————讲堂群(11)————————东门(12) n"); printf(" | | | | n"); printf(" | | | | n"); printf(" 研究生公寓(13)———工程训练中心(14)———南公教楼(15)——————信息楼(16) nn"); printf("n----------------------------------------------------------------------------n"); return 0; } int myMapDistance() { printf("n--------------------------------------平面图距离图开始--------------------------------------n"); printf("tt河北科技大学新校区平面图(括号内为相对应的数字编号)nn"); printf(" 西北操场(1)—————30—————校医院(2)—————200—————文法学院(3)—————60—————风雨操场(4) n"); printf(" | | | | n"); printf(" 300 310 500 50 n"); printf(" | | | | n"); printf(" 西门(5)——————400—————牧星湖(6)—————100—————公教楼(7)—————200—————主体育场(8) n"); printf(" | | | | n"); printf(" 300 50 200 200 n"); printf(" | | | | n"); printf(" 第三餐厅(9)—————200————图书馆(10)—————200————讲堂群(11)——————400——————东门(12) n"); printf(" | | | | n"); printf(" 300 350 600 600 n"); printf(" | | | | n"); printf(" 研究生公寓(13)——300———工程训练中心(14)——300———南公教楼(15)————300————信息楼(16) nnn"); printf("n--------------------------------------平面图距离图结束------------------------------------n"); return 0; } int initData() { int i, j; //向数组内装载数据 constructions[1].number = 1; strcpy(constructions[1].name, "西北操场"); strcpy(constructions[1].introduce, "学生运动,打篮、足球、排球、棒球的地方!(described by slience_me)n"); constructions[2].number = 2; strcpy(constructions[2].name, "校医院"); strcpy(constructions[2].introduce, "学生们,诊断看病的地方!(described by slience_me)n"); constructions[3].number = 3; strcpy(constructions[3].name, "文法学院"); strcpy(constructions[3].introduce, "文法相关专业学生上专业课的地方!(described by slience_me)n"); constructions[4].number = 4; strcpy(constructions[4].name, "风雨操场"); strcpy(constructions[4].introduce, "科大唯一的室内运动场,内含篮球场,羽毛球场等场地!(described by slience_me)n"); constructions[5].number = 5; strcpy(constructions[5].name, "西门"); strcpy(constructions[5].introduce, "这里是学校的西边出口,西大门!(described by slience_me)n"); constructions[6].number = 6; strcpy(constructions[6].name, "牧星湖"); strcpy(constructions[6].introduce, "科大学子,在闲暇之余,用来欣赏风景的地方,这里有山有水有瀑布!(described by slience_me)n"); constructions[7].number = 7; strcpy(constructions[7].name, "公教楼"); strcpy(constructions[7].introduce, "科大学子,用来上公共课的地方!大的地方!(described by slience_me)n"); constructions[8].number = 8; strcpy(constructions[8].name, "主体育场"); strcpy(constructions[8].introduce, "科大最主要的体育场,重大活动的场地,体育课,打球,运动的地方!(described by slience_me)n"); constructions[9].number = 9; strcpy(constructions[9].name, "第三餐厅"); strcpy(constructions[9].introduce, "学生第三食堂,主供新宿舍区域的食物供给!(described by slience_me)n"); constructions[10].number = 10; strcpy(constructions[10].name, "图书馆"); strcpy(constructions[10].introduce, "科大学子上自习备考,借阅图书的地方!十年图书馆必辉煌!(described by slience_me)n"); constructions[11].number = 11; strcpy(constructions[11].name, "讲堂群"); strcpy(constructions[11].introduce, "属于科大公共课最大的教室场地,一般用来举办讲座活动!(described by slience_me)n"); constructions[12].number = 12; strcpy(constructions[12].name, "东门"); strcpy(constructions[12].introduce, "科大的最东侧出口,也是科大的正门!(described by slience_me)n"); constructions[13].number = 13; strcpy(constructions[13].name, "研究生公寓"); strcpy(constructions[13].introduce, "研究生居住的宿舍!(described by slience_me)n"); constructions[14].number = 14; strcpy(constructions[14].name, "工程训练中心"); strcpy(constructions[14].introduce, "学生们进行金工实习,做实验的地方,内有各种仪器!(described by slience_me)n"); constructions[15].number = 15; strcpy(constructions[15].name, "南公教楼"); strcpy(constructions[15].introduce, "仅次于公教楼的第二个公共课开展场地!(described by slience_me)n"); constructions[16].number = 16; strcpy(constructions[16].name, "信息楼"); strcpy(constructions[16].introduce, "信息学子学习生活的场所!(described by slience_me)n"); for (i = 1; i <= Num; i++) { for (j = 1; j <= Num; j++) { edge[i][j] = Maxedge; } } for (i = 1; i <= Num; i++) { edge[i][i] = 0; } edge[1][2] = edge[2][1] = 30; edge[2][3] = edge[3][2] = 200; edge[3][4] = edge[4][3] = 60; edge[1][5] = edge[5][1] = 300; edge[2][6] = edge[6][2] = 310; edge[3][7] = edge[7][3] = 500; edge[4][8] = edge[8][4] = 50; edge[5][6] = edge[6][5] = 400; edge[6][7] = edge[7][6] = 100; edge[7][8] = edge[8][7] = 200; edge[5][9] = edge[9][5] = 300; edge[6][10] = edge[10][6] = 50; edge[7][11] = edge[11][7] = 200; edge[8][12] = edge[12][8] = 200; edge[9][10] = edge[10][9] = 200; edge[10][11] = edge[11][10] = 200; edge[11][12] = edge[12][11] = 400; edge[9][13] = edge[13][9] = 300; edge[10][14] = edge[14][10] = 350; edge[11][15] = edge[15][11] = 600; edge[12][16] = edge[16][12] = 600; edge[13][14] = edge[14][13] = 300; edge[14][15] = edge[15][14] = 300; edge[15][16] = edge[16][15] = 300; return 0; } char menu() { char i; printf("n--------------------------------------菜单开始--------------------------------------n"); printf("输入“s”以查询最短路径(the shortest path): n"); printf("输入“i”以查询地图名称介绍信息(the map information): n"); printf("输入“a”以查询全部地图名称介绍信息(all of the map information): n"); printf("输入“d”以查询地图距离信息(the map information of distance): n"); printf("输入“c”以获得小彩蛋(神龙): n"); printf("输入“q”以退出程序: n"); printf("请输入对应的英文小写字母,谢谢n"); printf("请输入:"); cin >> i; printf("--------------------------------------菜单结束--------------------------------------n"); return i; } int information() { int i; while (true) { printf("请输入查询地点的编号:"); cin >> i; printf("n--------------------------------------介绍开始--------------------------------------n"); if (i <= Num && i >= 1) { printf("nt@名称:%snt#简介:%sn", constructions[i].name, constructions[i].introduce); return 0; } else { printf("输入有误!"); } printf("n--------------------------------------介绍结束--------------------------------------n"); } return 0; } int informationAll() { printf("n--------------------------------------全部简介开始--------------------------------------n"); for (int i = 1; i < Num; i++) { printf("nt@名称:%snt#简介:%sn", constructions[i].name, constructions[i].introduce); } printf("n--------------------------------------全部简介结束--------------------------------------n"); return 0; } int fun() { cout << "nt111111111111111111111111111111111111111111111110000111111111111111111111111111111111111111111n" "t111111111111111111111111111111111111111111111000011111111111111111111111111111111111111111111n" "t111111111111111111111111111111111111111111100000011111111111111111111111111111111111111111111n" "t111111111111111111111111111111111111111110000001111000110000000000000001111111111111111111111n" "t111111111111111111111111111111110000000000000000000000000000000001111111111111111111111111111n" "t111111111111111111111111111111011100000000000000000000000000001111111111111111111111111111111n" "t111111111111111111111111111111111111100000000000000000000000000000000011111111111111111111111n" "t111111111111111111111111111111111000000000000000000000000000000011111111111111111111111111111n" "t111111111111111111111111111111110001110000000000000000000000000000011111111111111111111111111n" "t111111111111111111111111111110000011000000000001100000000000000000001111111111111111111111111n" "t111111111111111111111111111100000000000000010011110000000000000110000011111111111111111111111n" "t111111111111111111111111000000000000000000111011111000000000000011100001111111111111111111111n" "t111111111111111111111100000000000000000001111111110000000000000001111000111111111111111111111n" "t111111111111111111111000000001111111111111111111110000000000000000111110011111111111111111111n" "t111111111111111111111100000111111111111111111111000000000000000000111111111111111111111111111n" "t111111111111111111111111011111111111111111110000000000000000000000011111111111111111111111111n" "t111111111111111111111111111111000000000000000000000000000000000000011111111111111111111111111n" "t111111111111111111111111111111110000000000000000000000000000110000011111111111111111111111111n" "t111111111111111111111111111100000000000000000000000000000011110000011111111111111111111111111n" "t111111111111111111111111100000000000000000000000000000000111111000011111111111111111111111111n" "t111111111111111111111110000000000000000000000000000000111111111000011111111111111111111111111n" "t111111111111111111111000000000000000000000000000000011111111111000011111111111111111111111111n" "t111111111111111111110000000000000000000111000000111111111111111000111111111111111111111111111n" "t111111111111111111100000000000000001111111111111111111111111111001111111111111111111111111111n" "t111111111111111111000000000000000111111111111111110011111111111111111111111111111111111111111n" "t111111111111111110000000000000001111111111111111111110000111111111111111111111111111111111111n" "t111111111111111110000000000100011111111111111111111111100000111111111111111111111111111111111n" "t111111111111111100000000000110011111111111111111111111111000000011111111111111111111111111111n" "t111111111111111100000000000011101111111111110001111100001110000000111111111111111111111111111n" "t111111111111111100000000000001111111111111111100011111000000000000001111111111111111111111111n" "t111111111111111100000000000000001111111111111100000000000000000000000011111111111111111111111n" "t111111111111111100100000000000000000111111111000000000000000000000000000111111111111111111111n" "t111111111111111110011000000000000111111111000000000000000011100000000000011111111111111111111n" "t111111111111111111011000000000000000000000000000000000011111111111000000001111111111111111111n" "t111111111111111111111000000000000000000000000000000000111111111111110000000111111111111111111n" "t111111111111111111111000001000000000000000000110000000011101111111111000000111111111111111111n" "t111111111111111111111100011111000000000000011111000000000011111111111011000011111111111111111n" "t111111111111111111111000111111110001000000000111110000011111111111111111000011111111111111111n" "t111111111111111111111000111111111111111000000011111110000000011111111111100011111111111111111n" "t111111111111111111111100111111111111111111100000011111111111111111111111110001111111111111111n" "t- ------------------------------ 神龙保佑,永无BUG --------------------------------- -n"; return 0; } int floyd() { int i = 1, j = 1, k = 1, l = 1; for (i = 1; i <= Num; i++) { for (j = 1; j <= Num; j++) { shortest[i][j] = edge[i][j]; path[i][j] = 0; } } for (k = 1; k <= Num; k++) { for (i = 1; i <= Num; i++) { for (j = 1; j <= Num; j++) { if (shortest[i][j] > (shortest[i][k] + shortest[k][j])) { shortest[i][j] = (shortest[i][k] + shortest[k][j]); path[i][j] = path[j][i] = k; } } } } return 0; } int way(int i, int j) { int k = 0, a = i, b = j; if (shortest[i][j] != Maxedge) { printf("n从 (%s) 到 (%s) 的最短路径为:n", constructions[i].name, constructions[j].name); printf("(%s)", constructions[i].name); while (path[i][j] != 0) { k = path[i][j]; while (path[i][k] != 0) { k = path[i][k]; } printf("-->(%s)", constructions[k].name); i = k; } printf("-->(%s);n", constructions[j].name); printf("n最短距离为:(%d)米。n", shortest[a][b]); printf("n数据均为测试数据,与实际有误差,敬请谅解.nn"); } else printf("从%s不能到达%s。", constructions[i].name, constructions[j].name); return 0; } int shortestpath() { int i = 0, j = 0; while (true) { printf("请输入要查询的两点的编号:(以空格间隔): "); cin >> i >> j; if (i <= Num && i > 0 && j <= Num && j > 0) { floyd(); way(i, j); return 0; } } return 0; } int main() { char i; printf("n----------------------------------------------------------------------------n"); printf("ttt欢迎使用河北科技大学新校区导航系统nn"); initData(); myMap(); while (true) { i = menu(); switch (i) { case 's': shortestpath(); break; case 'i': information(); break; case 'a': informationAll(); break; case 'd': myMapDistance(); break; case 'c': fun(); break; case 'q': printf("nnntttt谢谢使用!n"); return (0); default : printf("输入错误!n"); break; } } return 0; }



