資源簡介
C實現校園導航系統,至少包括10個以上的場所.
每倆個場所間可以有不同的路,選擇最短的路徑.
實現校園導航
代碼片段和文件信息
#define?INFINITY?10000?
#define?MAX_VERTEX_NUM?40?
#define?MAX?40?
#include?
#include?
#include?
#include?
typedef?struct?ArCell?
{?
int?adj;?/*路徑長度?*/
}ArCellAdjMatrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM];?
typedef?struct?/*圖中頂點表示主要景點,存放景點的編號、名稱、簡介等信息,?*/
{?
char?name[30];?
int?num;?
char?introduction[100];/*簡介*/?
}infotype;?
typedef?struct?
{?
infotype?vexs[MAX_VERTEX_NUM];?
AdjMatrix?arcs;?
int?vexnumarcnum;?
}MGraph;?
MGraph?b;?
void?cmd(void);?
MGraph?InitGraph(void);?
void?Menu(void);?
void?Browser(MGraph?*G);?
void?ShortestPath_DIJ(MGraph?*?G);?
void?Floyd(MGraph?*G);?
void?Search(MGraph?*G);?
int?LocateVex(MGraph?*Gchar*?v);?
MGraph?*?CreatUDN(MGraph?*G);?
void?print(MGraph?*G);?
/******************************************************/?
void?main(void)?
{?
system(“color?1f“);?
system(“mode?con:?cols=140?lines=130“);?
cmd();?
}?
/******************************************************/?
void?cmd(void)?
{?
int?i;?
b=InitGraph();?
Menu();?
scanf(“%d“&i);?
while(i!=5)?
{?
switch(i)?
{?
case?1:system(“cls“);Browser(&b);Menu();break;?
case?2:system(“cls“);ShortestPath_DIJ(&b);Menu();break;?
case?3:system(“cls“);Floyd(&b);Menu();break;?
case?4:system(“cls“);Search(&b);Menu();break;?
case?5:exit(1);break;?
default:break;?
}?
scanf(“%d“&i);?
}?
}?
MGraph?InitGraph(void)?
{?
MGraph?G;?
int?ij;?
G.vexnum=10;?
G.arcnum=14;?
for(i=0;i G.vexs[i].num=i;?
strcpy(G.vexs[0].name“北園食堂“);?
strcpy(G.vexs[0].introduction“南園食堂“);?
strcpy(G.vexs[1].name“物理樓“);?
strcpy(G.vexs[1].introduction“數計樓,樓高4層“);?
strcpy(G.vexs[2].name“5號學生宿舍樓“);?
strcpy(G.vexs[2].introduction“計算機系男生宿舍樓,蘇式建筑“);?
strcpy(G.vexs[3].name“醫務室“);?
strcpy(G.vexs[3].introduction“校醫院設施一般“);?
strcpy(G.vexs[4].name“圖書館“);?
strcpy(G.vexs[4].introduction“藏書百萬冊設施良好,環境幽雅“);?
strcpy(G.vexs[5].name“足球場“);?
strcpy(G.vexs[5].introduction“現代化塑膠跑道人造草坪適宜鍛煉身體的場所“);?
strcpy(G.vexs[6].name“陶園“);?
strcpy(G.vexs[6].introduction“綠樹成蔭適宜休息和讀書“);?
strcpy(G.vexs[7].name“主教學樓“);?
strcpy(G.vexs[7].introduction“學院最大的教學樓共20層,環形建筑適宜學習“);?
strcpy(G.vexs[8].name“化學樓“);?
strcpy(G.vexs[8].introduction“設施良好“);?
strcpy(G.vexs[9].name“體育樓“);?
strcpy(G.vexs[9].introduction“運動設施先進環境良好“);?
for(i=0;i for(j=0;j G.arcs[i][j].adj=INFINITY;?
G.arcs[0][1].adj=100;?
G.arcs[0][2].adj=200;?
G.arcs[0][6].adj=400;?
G.arcs[1][7].adj=300;?
G.arcs[2][3].adj=120;?
G.arcs[3][6].adj=220;?
G.arcs[3][4].adj=100;?
G.arcs[4][5].adj=300;?
G.arcs[4][9].adj=250;?
G.arcs[5][9].adj=350;?
G.arcs[6][7].adj=60;?
G.arcs[6][9].adj=200;?
G.arcs[7][8].adj=50;?
G.arcs[8][9].adj=20;?
for(i=0;i for(j=0;j G.arcs[j][i].adj=G.arcs[i][j].adj;?
return?G;?
}//InitGraph?end?
void?Menu()?
{?
printf(“\n?鹽城師范學院導游圖\n“);?
printf(“?┏━━━━━━━━━━━━━━━━━━━━┓\n“);?
printf(“?┃?1.瀏覽校園全景?┃\n“);?
printf(“?┃?2.查看所有游覽路線?┃\n“);?
print
- 上一篇:數據鏈路層設計與實現
- 下一篇:解析S57海圖數據代碼
評論
共有 條評論