全国交通咨询模拟系统源代码

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

12050741班(郭晓湛,李佳豪,廖川,杨鹤)

课题:全国交通系统咨询模拟

源程序代码:

#include

#include

#include

#include

#include

#include

#define INF 65535 //定义一个最大数定为无穷值#define MAX 23

using namespace std;

static int c_number=10;

static int k=0;

static int v=0,z=0,r=0,t=0;

typedef struct search

{

int c_transer;

int c_cost;

int c_time;

int f_cost;

int f_time;

}search;

search m[20],x[20],n[20];

typedef int costAdj[MAX+1][MAX+1];//图邻接矩阵从1开始记数int Path[MAX+1][MAX+1];//图邻接矩阵从1开始记数

typedef struct unDiGraph

{

int numVerts; //结点

costAdj cost; //邻接矩阵

}unDiGraph,*UNG; //图的定义

typedef struct c_edit

{

char a[10];

}c_edit;

c_edit add[10];

costAdj B,L;

//定位函数,输出城市列表,增添城市。

int pr(int i,int j)

{

int h=0;

if (j==0)

{

h=i;

}

else if (j==1)

{

cin>>add[i].a;

}

switch(h)//运用switch语句。

{

case(0):cout<<"";break;

case(1) : cout<<"成都 ";break; case(2) : cout<<"西安 ";break; case(3) : cout<<"郑州 ";break; case(4) : cout<<"武汉 ";break; case(5) : cout<<"株洲 ";break;

case(6) : cout<<"贵阳 ";break;

case(7) : cout<<"柳州 ";break;

case(8) : cout<<"广州 ";break;

case(9) : cout<<"南宁 ";break;

case(10) : cout<<"徐州 ";break;

default:

cout<

}

return 1;

}

//输出城市列表及相应代码

void pri()

{

int i;

cout<<" 城市及其代码"<

cout<<"****************************"<

{

cout<

pr(i,0);

}

cout<

}

//构造带权(费用)图返回首地址G:

unDiGraph *CreateCostG(int o)//火车的花费的存贮和编辑功能{

unDiGraph *G;

int i,j;

int a=0,b=0,f,h=1;

if(!(G=(unDiGraph *)malloc(sizeof(unDiGraph)))) //为G 分配存储空间。

{

return(NULL);

}

for(i=1;i

{

for(j=1;j

{

G->cost[i][j]=INF; //初始化使G->cost[i][j]为无穷。

}

}

G->numVerts=c_number;

G->cost[1][2]=G->cost[2][1]=112;

G->cost[1][6]=G->cost[6][1]=190;

G->cost[2][3]=G->cost[3][2]=136;

G->cost[2][5]=G->cost[5][2]=325;

G->cost[3][4]=G->cost[4][3]=142;

G->cost[3][5]=G->cost[5][3]=230;

G->cost[3][6]=G->cost[6][3]=213;

G->cost[4][7]=G->cost[7][4]=247;

G->cost[4][8]=G->cost[8][4]=250;

G->cost[5][7]=G->cost[7][5]=161;

G->cost[5][9]=G->cost[9][5]=208;

G->cost[5][10]=G->cost[10][5]=261;

G->cost[6][8]=G->cost[8][6]=317;

G->cost[7][8]=G->cost[8][7]=208;

G->cost[8][10]=G->cost[10][8]=367;

G->cost[9][10]=G->cost[10][9]=444;

if (o)

{

while(h==1)

{

v=v+1;

相关文档
最新文档