校园导游咨询系统-数据结构课程设计|数据结构课程设计
校园导游咨询代码包含两个文件,请注意 校园导游咨询
/********************以下是a.c文件********************/
#include "stdafx.h"#using
#include #include #include
struct message{int num;char name[100];char pro[500];}school[10]={{1,"行政楼\n"},{2,"食堂\n"},{3,"赛博楼,信息分院办公室所在地\n"},{4,"求是楼,实验楼计算机中心\n"},{5,"格致楼,法学管理学院"},{6,"工程实习中心,金工实习\n"},{7,"仰仪楼,机电计测分院\n"},{8,"体育馆,旁边有篮球场`足球场`还有网球场\n"},{9,"一号教学楼,主要以阶梯教室为主\n"},{10,"二号教学楼,小教室为多\n"}};#define maxlong 10void road(int c[10][10],int a,int b)
{int i,j,k,next;int max=1000;int path[maxlong][maxlong],A[maxlong][maxlong];for(i=0;i<10;i++)for(j=0;j<10;j++){if(c[j]!=max) path[j]=j;else path[j]=0;A[j]=c[j];}for(k=0;k<10;k++)for(i=0;i<10;i++)for(j=0;j<10;j++)if(A[j]>(A[k]+A[k][j])){A[j]=A[k]+A[k][j];path[j]=path[k];}printf("%d\n",A[a-1][b-1]);next=path[a-1][b-1];if(next==-1)printf("没有此路径\n");else{printf("%d",a);while(next!=(b-1)){printf("-->%d",next+1);next=path[next][b-1];}printf("-->%d\n",b);}}void result(int a)
{printf("%s,%s\n",school[a-1].name,school[a-1].pro);}
using namespace System;
int _tmain(){int A[10][10]={{0,15,100,45,50,450,35,550,80,90},{15,0,85,30,35,435,20,535,65,75},{100,85,0,30,60,400,420,380,355,520},{45,30,30,0,20,300,280,230,270,490},{50,35,60,20,0,320,700,580,260,450},{450,435,400,280,320,0,100,140,160,200},{35,20,420,280,700,100,0,40,60,180},{550,535,380,230,580,40,40,0,20,160},{80,65,355,270,260,160,60,20,0,120},{90,75,520,490,450,200,180,160,120,0}};int a,b,c;printf("1行政楼,2食堂,3赛博楼,4求是楼,5格致楼,6工程实习中心,7仰仪楼,8体育馆,9一号教学楼,10二号教学楼\n");printf("请输入起点和终点的代码:");scanf("%d,%d",&a,&b);road(A,a,b);printf("输入想知道的景点的代码:");scanf("%d",&c);result(c);}
/*********************一下是q.c文件***********************/
#include "stdio.h"#define null 0 /*宏替换*/#define num 20#define maxdist 10000typedef struct /*定义结构体存景点代码、名称、简介*/{ int code; char name[num]; char pr[num];}graph;void save( int c[num][num],int n,int i,int d[num],int p[num]) /*最短路径的C语言函数*/{ int s[num]; int mindist,dist; int j,k,u,w; for(j=0;j if(dist
{1,"forest","tree and grass"}, {2,"restaurant","eat food"}, {3,"building","teaching room"}, {4,"expriment","action myself"}, {5,"gate","shool gate"}, {6,"playground","playing ball"}, {7,"life-center","service center"}, {8,"super market","buy evergthing"}, {9,"camera room","see movie"}}; int i,j,k,n=10; int d[num],p[num],sd[num][num],sp[num][num],a[num][num]; clrscr(); for(i=0;i9: (!=0->9 q)\n"); scanf("%d",&i); if(i<0||i>9) /*输入非0->9退出*/
break; printf("%s,%s\n",pl[i].name,pl[i].pr); } }break; case'c': clrscr();break; /*界面清屏*/ case'v': { /*输入景点代码查到其它景点的最短距离*/ do { printf("\ninput the number:(0-9): (!=0->9 q)\n"); scanf("%d",&i); if(i<0||i>9) /*输入非0->9退出*/ break; save(a,n,i,d,p); printf("\n\nThe shortroad is:\n"); input(i,n,d,p);
} while(1); }break; default: exit(1); /*非正常字符退出*/ } } while(getchar()); getchar();}