校园导游咨询系统

/********************以下是a.c文件********************/

#include "stdafx.h"
#using <mscorlib.dll>
#include <math.h>
#include <string.h>
#include <stdio.h>

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 10

{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);
printf("输入想知道的景点的代码:");
scanf("%d",&c);
result(c);
}

/*********************一下是q.c文件***********************/

#include  "stdio.h"
#define   null    0                                            /*宏替换*/
#define   num     20
#define   maxdist 10000
typedef   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<n;j++)
{
d[j]=c[i][j];
s[j]=0;
if((d[j]<maxdist)&&(d[j]!=0))
p[j]=i;
else
p[j]=-1;
}
s[i]=1;
for(j=0;j<n-1;j++)
{
mindist=maxdist;
u=i;
for(k=0;k<n;k++)
if((s[k]==0)&&(d[k]<mindist))
{
u=k;
mindist=d[k];
}
s[u]=1;
for(k=0;k<n;k++)
if(s[k]==0)
{
dist=d[u]+c[u][k];

if(dist<d[k])
{
d[k]=dist;
p[k]=u;
}
}
}
}
void input(int v,int n,int d[],int p[])                     /*输出最短路径和最短距离函数*/
{
int i,j,k,pre;
for(i=0;i<n;i++)
if(i!=v)
{
printf("\n%d",i);
pre=p[i];
while(pre!=-1)
{
printf("<--%d",pre);                             /*输出最短路径所经过的景点*/
pre=p[pre];
}
if(d[i]==maxdist)
printf("<--%d",v);
printf("\tshortestway:%d",d[i]);                   /*输出最短距离*/
}
}
main()                                                      /*程序主函数*/
{
graph   pl[10]={{0,"classroom","go to class"},         /*景点名称和简介*/

[1] [2] [3] 下一页