资源简介
数据结构课程设计,用哈弗曼函数实现,并保存在文件中,读取文件中信息,实现最短路径,最少花费的算法,有飞机和列车两种方式的查询

代码片段和文件信息
#define MAX_VERTEX_NUM 18
#define NULL 0
#define MAX_ARC_SIZE 100
#define MAX_ROUTE_NUM 5
#include“stdio.h“
#include“stdlib.h“
#include“string.h“
#define False 0
#define True 1
#define INFINITY 10000
typedef struct
{
int number;
float expenditure;
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];
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;
typedef struct QNode
{
int adjvex;
struct QNode *next;
}QNode;
typedef struct
{
QNode *front;
QNode *rear;
}linkQueue;
typedef struct TimeNode
{
int adjvex;
int route;
int begintime[2];
int arrivetime[2];
struct TimeNode *child[MAX_ROUTE_NUM];
}TimeNode*TimeTree;
struct arc
{
int co;
char vt[10];
char vh[10];
int bt[2];
int at[2];
float mo;
}a[MAX_ARC_SIZE];
char city[MAX_VERTEX_NUM][10];
int TTime[2];
int time[2];
int time1[2];
int time2[2];
int c[MAX_VERTEX_NUM];
int d[MAX_VERTEX_NUM];
createcityfile() /*创建城市名称文档*/
{int i=0;
int j;
char flag=‘y‘;
FILE *fp;
printf(“\n请输入城市名称的信息:\n“);
while(flag==‘y‘||flag==‘Y‘)
{printf(“城市名称:“);
gets(city[i]);
i++;
printf(“继续输入?(Y/N)“);
scanf(“%c“&flag);
getchar();
}
printf(“\n“);
if((fp=fopen(“city.txt““wb+“))==NULL)
{printf(“无法打开文件!\n“);
return;
}
for(j=0;j fprintf(fp“%10s“city[j]);
fclose(fp);
}
createplanefile() /*创建飞机航班文档*/
{int codebt[2]at[2];
float money;
int i;
int count;
char vt[10]vh[10]flag;
FILE *fp;
flag=‘y‘;
count=0;
while(flag==‘Y‘||flag==‘y‘)
{printf(“请输入飞机航班的信息:\n“);
printf(“飞机航班编号:“);
scanf(“%d“&code);
getchar();
printf(“起始城市:“);
gets(vt);
printf(“目的城市:“);
gets(vh);
printf(“航班费用:“);
scanf(“%f“&money);
getchar();
printf(“起飞时间:“);
scanf(“%d:%d“&bt[0]&bt[1]);
getchar();
while(bt[0]<0||bt[0]>=24||bt[1]<0||bt[1]>=60)
{printf(“\n时间输入有误,请重新输入\n“);
scanf(“%d:%d“&bt[0]&bt[1]);
getchar();
}
printf(“到达时间:“);
scanf(“%d:%d“&at[0]&at[1]);
getchar();
while(at[0]<0||at[0]>=24||at[1]<0||at[1]>=60)
{printf(“\n时间输入有误,请重新输入\n“);
scanf(“%d:%d“&at[0]&at[1]);
getchar();
}
a[count].co=code;
strcpy(a[count].vtvt);
strcpy(a[count].vhvh);
a[count].bt[0]=bt[0];
a[count].bt[1]=bt[1];
a[count].at[0]=at[0];
a[count].at[1]=at[1];
a[count].mo=money;
count++;
printf(“继续输入?(Y/N)“);
scanf(“%c“&flag);
getchar();
printf(“\n“);
}
if((fp=fopen(“plane.txt““wb+“))==NULL)
printf(“\n无法打开文件!\n“);
fprintf(fp“%d“count);
for(i=0;i if(fwrite(&a[i]sizeof(struct arc)1fp)!=1)
print
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2010-12-02 17:06 交通咨询系统\
文件 41210 2010-10-12 10:46 交通咨询系统\交通咨询系统.cpp
- 上一篇:网络端口扫描工具
- 下一篇:89c51电子数字钟 源码和电路图
相关资源
- The Secret Path 3D 3D魔方迷宫[源码][scra
- 数据结构年终考题范围和答案 耿国华
- 用汇编实现的学生成绩档案管理系统
- 数据结构 朱战力 习题解答 数据结构
- 数据结构课程设计 6 1 彩票系统
- 教学计划编制系统
- PC -- 单片机的串口数据传输系统设计
- 大数(链表、数组)实现
- 自己写的航空订票系统c 版--数据结构
- 数据结构实验魔王语言
- 航空订票系统_数据结构课程设计
- 多项式求和(数据结构C 版)
- 尚观培训linux董亮老师关于数据结构的
- 数据结构 知识点总结
- 高校排课系统设计与实现
- 华南理工大学数据结构复习提纲二
- 华南理工大学数据结构复习提纲一
- 数据结构用C 写的停车场系统源代码
- 基于AT89C51的数据采集系统设计新方法
- 数据结构(河北科技大学)
- 数据结构考前习题 清华大学出版社
- 数据结构课件(北邮)
- 数据结构实验 基于栈的表达式求值
- 数据结构课程设计——图书管理系统
- 新闻发布系统设计与实现
- 成绩管理系统(数据结构)
- 数据结构-最小通信网问题
- 数据结构课程设计同学通讯录系统
- 数据结构课程设计 公园导游图
- 迷宫问题 maze 迷宫算法的实现
评论
共有 条评论