• 大小: 346KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-07-18
  • 语言: 其他
  • 标签:

资源简介

城市之间有三种交通工具(汽车、火车和飞机)相连,某旅客于某一时刻向系统提出旅行要求,系统根据该旅客的要求为其设计一条旅行线路并输出;系统能查询当前时刻旅客所处的地点和状态(停留城市/所在交通工具)。

资源截图

代码片段和文件信息

#include 
#include 
#include 
#include 
#include 
#include 
#define MAX_VERTEX_NUM 50 //最大顶点数,即最大城市数目 
#define MAX_ARC_SIZE 2000 //最大边数 
#define MAX_ROUTE_NUM 30  //最大路线数 
#define VEHICLE_NAME_LENGTH 10
#define INFINITY 100000.0
#define TRAIN 0
#define PLANE 1 

typedef struct { //The definition of PathNode in which stores the infomation of the path
char vehName[VEHICLE_NAME_LENGTH]; //The name of the vehicle
int n; //The order of this node in the path.
float fare; //The fare it costs.
int arrival; //The arrival time.
int departure; //The departure time.
} PathNode;

/*
Three kinds of strategy.
*/
#define TIME 1
#define FARE 2
#define TRANSFER 3
#define False 0
#define True 1



typedef struct
{
char codenum[10];
float expense; //费用 
    int begintime[2]; //始发时间 
    int arrivetime[2]; //到达时间 
}Vehide;

typedef struct
{
Vehide stata[MAX_ROUTE_NUM];
    int last;
}infolist;

typedef struct ArcNode
{
int adjvex;
struct ArcNode *nextarc;
    infolist info;
}ArcNode;

typedef struct VNode
{
char cityname[10]; //允许城市名最大长度为10 
ArcNode *planefirstarc*trainfirstarc;
}VNodeAdjList[MAX_VERTEX_NUM];

typedef struct
{
AdjList vertices;
    int vexnumplanearcnumtrainarcnum;
}ALGraph;

typedef struct Node
{
int adjvex;
    int route;
    struct Node *next;
}Node;



 
struct arc
{
char co[10]; //记录车次编码 
    char vt[10]; //记录始发城市 
    char vh[10]; //记录到达城市 
    int bt[2]; //begintime 
    int at[2]; //arrivetime 
    float mo; //money 
}a[MAX_ARC_SIZE];

char city[MAX_VERTEX_NUM][10];
int TTime[2];
int ttime[2];
int time1[2];
int time2[2];
int c[MAX_VERTEX_NUM];
int d[MAX_VERTEX_NUM];
void Administer(ALGraph *G);//管理员模式 
void UserMode(ALGraph *G);
void ModiCity(ALGraph *G);//城市信息维护 
void CreateCity();//创建城市 
void CreateGraph(ALGraph *G);//读入文件,创建交通图 
void CreatePlane();//创建航班 
void CreateTrain();//创建列车 
int DeletePlane(ALGraph *G);//删除航班 
int DeleteTrain(ALGraph *G);//删除列车 
void DeleteCity(ALGraph *G);//删除城市 
void AddPlane(ALGraph *G);//添加航班 
void AddTrain(ALGraph *G);//添加列车 
void AddCity(ALGraph *G);//添加城市 
void ModiFlight(ALGraph *G);//修改航班 
void InitGraph(ALGraph *G);//初始化函数 
int LocateCity(ALGraph *Gchar *v);//定位城市 
void PrintGraph(ALGraph *G);//打印交通图(显示交通信息) 
int Save(ALGraph *G);//将输入、修改的信息保存到file 
void ModiTrain(ALGraph *G);//修改列车 
void printGraph(ALGraph *pG);
int trafficAnaly(ALGraph *pG char* o_name char* t_name int strategy int vk PathNode **path);
void copyPath(PathNode P1[] PathNode P2[] int vexnum);
int getPath(PathNode *P int vexNum int **path);
void printPath(ALGraph G PathNode *P int *path int n);
void find(ALGraph *pG char* o_name char* t_name int strategy int vk);

int mark=0;//专门设立的mark标识,当未进行数据初始化时,mark=0,要求先进行初始化操作,再进行其他操作。实际运用中可删除。 


int main()
{
 ALGraph G;

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-03-25 22:07  全国交通咨询模拟\
     文件        5062  2016-03-25 22:04  全国交通咨询模拟\admin.txt
     文件         260  2016-01-12 11:35  全国交通咨询模拟\city.txt
     文件        2380  2016-01-12 12:15  全国交通咨询模拟\plane.txt
     文件         896  2016-01-16 18:50  全国交通咨询模拟\security.txt
     文件          72  2016-01-16 18:49  全国交通咨询模拟\service.txt
     文件        4949  2016-01-12 11:35  全国交通咨询模拟\train.txt
     文件       47383  2016-03-25 22:07  全国交通咨询模拟\Transportation.cpp
     文件      443370  2016-03-25 22:07  全国交通咨询模拟\Transportation.exe
     文件         991  2016-01-16 18:56  全国交通咨询模拟\【使用说明】.txt
     文件      235042  2016-01-16 01:57  全国交通咨询模拟\全国交通咨询模拟实验报告.docx

评论

共有 条评论

相关资源