diff --git a/城市地铁导航系统.c b/城市地铁导航系统.c deleted file mode 100644 index a60cec9..0000000 --- a/城市地铁导航系统.c +++ /dev/null @@ -1,205 +0,0 @@ -#include -#include -#include - #define MAX 1000 - typedef struct node { - char a[100]; - struct node* next; -}edgenode; - typedef struct { - char name[100]; - edgenode* firstnode; -}vexnode; - typedef struct { - vexnode adjust[7]; - int e, n; -}list; - list nm; - void creatnode() {//对节点进行初始化 - nm.e = 7;//边数 - nm.n = 7;//站点数 - strcpy(nm.adjust[0].name, "肇嘉浜路"); - strcpy(nm.adjust[1].name, "东安路"); - strcpy(nm.adjust[2].name, "上海体育场"); - strcpy(nm.adjust[3].name, "嘉善路"); - strcpy(nm.adjust[4].name, "大木桥路"); - strcpy(nm.adjust[5].name, "徐家汇"); - strcpy(nm.adjust[6].name, "上海体育馆"); - int i; - for (i = 0; i < nm.n; i++) { - nm.adjust[i].firstnode = NULL; - } -} - void createlist() { - edgenode *p; - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "东安路"); - p->next = nm.adjust[0].firstnode; - nm.adjust[0].firstnode = p; - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "嘉善路"); - p->next = nm.adjust[0].firstnode; - nm.adjust[0].firstnode = p; - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "徐家汇"); - p->next = nm.adjust[0].firstnode; - nm.adjust[0].firstnode = p; - //下面是东安路的邻接表 - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "肇嘉浜路"); - p->next = nm.adjust[1].firstnode; - nm.adjust[1].firstnode = p; - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "上海体育场"); - p->next = nm.adjust[1].firstnode; - nm.adjust[1].firstnode = p; - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "大木桥路"); - p->next = nm.adjust[1].firstnode; - nm.adjust[1].firstnode = p; - //下面是上海体育场的邻接表 - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "东安路"); - p->next = nm.adjust[2].firstnode; - nm.adjust[2].firstnode = p; - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "上海体育馆"); - p->next = nm.adjust[2].firstnode; - nm.adjust[2].firstnode = p; - //下面是嘉善路的邻接表 - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "大木桥路"); - p->next = nm.adjust[3].firstnode; - nm.adjust[3].firstnode = p; - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "肇嘉浜路"); - p->next = nm.adjust[3].firstnode; - nm.adjust[3].firstnode = p; - //下面是大木桥路 - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "东安路"); - p->next = nm.adjust[4].firstnode; - nm.adjust[4].firstnode = p; - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "嘉善路"); - p->next = nm.adjust[4].firstnode; - nm.adjust[4].firstnode = p; - //下面是徐家汇 - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "肇嘉浜路"); - p->next = nm.adjust[5].firstnode; - nm.adjust[5].firstnode = p; - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "上海体育馆"); - p->next = nm.adjust[5].firstnode; - nm.adjust[5].firstnode = p; - //下面是上海体育馆 - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "徐家汇"); - p->next = nm.adjust[6].firstnode; - nm.adjust[6].firstnode = p; - p = (edgenode*)malloc(sizeof(edgenode)); - strcpy(p->a, "上海体育场"); - p->next = nm.adjust[5].firstnode; - nm.adjust[6].firstnode = p; -} - int cont[100][100];//邻接矩阵 - void aaa(){ - int i,j; - for(i=0;ia,nm.adjust[h].name)) break; - cont[i][h]=1; - p=p->next; - } - } -} - void print() { - edgenode* p; - int i; - for(i=0;i[%s]",p->a); - p=p->next; - } - printf("\n"); - } -} -int num2=0; - void Dijkstra(int v1,int v2){ - int dist[MAX],s[MAX],path[MAX];//s判断v1是否已经判断最短路径,path前驱 - int min,i,j,u,pre; - for(i=0;i",nm.adjust[pre].name); - pre=path[pre]; - } - printf("%s",nm.adjust[pre].name); - } - else printf("路径不存在!\n"); - } - } -} -int main() -{ - creatnode(); - createlist(); - int n=10; - printf("正在初始化数据,请稍候!\n"); - //proc(); - printf("欢迎使用本系统!\n"); - while(n){ - printf("欢迎来到上海市地铁交通服务平台!\n"); - printf(" 最佳出行线路推荐\n"); - printf(" 退出系统!\n"); - printf("请输入!\n"); - scanf("%d",&n); - } - return 0; - }