资源简介
数据结构,可以作为大作业,详细的注释以及严谨的编码风格,为大二编写的还是很学生化得,而且有说明文档

代码片段和文件信息
#include
#include
#include
#include
using namespace std;
#define CITYNUM 24
#define MAXINT 100000
struct TimeMy
{
int Hour;
int Minute;
int operator<(TimeMy time2);//小于重载
int operator-(TimeMy time2);//减号重载
int operator+(int time);//加好重载
};
int TimeMy::operator +(int time)
{
return 60*Hour+Minute+time;
}
int TimeMy::operator <(TimeMy time2)
{
if(Hour==time2.Hour)
if(time2.Minute return 1;
else
return 0;
if(Hour return 1;
else
return 0;
}
int TimeMy::operator -(TimeMy time2)
{
return 60*(Hour-time2.Hour)+Minute-time2.Minute;
}
//输出操作重载
ostream operator<<(ostream &outTimeMy time)
{
out< out< out< return out;
}
//输入操作重载
istream operator>>(istream &inTimeMy &time2)
{
char buff[5];
in>>buff;
buff[2]=‘\0‘;
time2.Hour=atoi(&buff[0]);//前两个字符转换成整型
time2.Minute=atoi(&buff[3]);//后两个字符转换成整型
buff[2]=‘0‘;//我怕造成内存泄漏
return in;
}
/*//时间类测试
int main()
{
TimeMy time1time2;
cin>>time1>>time2;
cout< cout<<(time1 cout<<(time2 cout< return 0;
}*/
//一个航班或是车列的记录
struct TFNum
{
string ID;
TimeMy Start;
TimeMy End;
float Cost;
TimeMy Long;
};
struct TGraph
{
TFNum tfnum[CITYNUM][CITYNUM][3];//全部车次或航班邻接矩阵
int num[CITYNUM][CITYNUM];//num[x1][x2]表示tfnum[x1][x2]的第三维有num[x1][x2]个车次
void output();
};
void TGraph::output()
{
for(int i=0;i for(int j=0;j for(int t=0;t cout< < < < < }
//所有人注意:你的程序要是用到多次使用的很大数据,避免重复生成,就在各自数据域定义成全局变量,但要记得销毁
//全局变量
//公共数据域
//该域数据只在程序的开始根据记录文件初始化并不再改动
string city[CITYNUM];
//用于计算费用最少的航班、车次路线的辅助变量域
typedef TFNum MGraph[CITYNUM][CITYNUM];
MGraph tmgraph;//最省车次邻接矩阵
MGraph pmgraph;//最省航班邻接矩阵
//用于计算时间最少的航班、车次路线的辅助变量域
TGraph ttgraph;//车次的邻接矩阵
TGraph ptgraph;//航班的邻接矩阵
//函数声明
void InitMGraph(const char* filenameMGraph &mgraph);
void InitTGraph(const char* filenameTGraph &tgraph);
//所有的小组成员注意,数据结构是各个函数的连接桥梁,
//所以编写的时候一定按照规定的数据结构编写,若对数据进行修改一定要小组讨论决定
//函数定义
//用于航班和车次数据的修改,函数调用中用户选择修改航班还是车次
//从起点城市查找记录,并进行修改,并调用相应辅助变量图初始化函数
void chosetype(int typestring &filename)
{
if(type==0)
filename=“plane.txt“;
if(type==1)
filename=“train.txt“;
if(type!=1&&type!=0)
filename=“none“;
}
void modify(int type)
{
fstream file;
string filename;
chosetype(typefilename);
file.open(filename.c_str());
if(!file)
{
cout<<“数据文件丢失或选择操作数据错误!“< return ;
}
string startcitybuffscity;
cout<<“请输入所修改数据的起点站“< cin>>scity;
getline(filebuff);
file>>startcity;
while(!file.eof())
{
file>>buff;
if(startcity==scity)
break;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 17633 2009-06-18 19:04 全国交通咨询模拟系统\fr
文件 3068 2009-06-14 10:18 全国交通咨询模拟系统\plane.txt
文件 6533 2009-06-15 19:00 全国交通咨询模拟系统\train.txt
文件 175616 2009-06-18 22:51 全国交通咨询模拟系统\全国交通咨询系统设计报告.doc
目录 0 2009-06-18 22:56 全国交通咨询模拟系统
----------- --------- ---------- ----- ----
202850 5
- 上一篇:基于AT89S52单片机的数字温度计
- 下一篇:MRMR(最小冗余最大相关算法
相关资源
- 数据结构年终考题范围和答案 耿国华
- 数据结构 朱战力 习题解答 数据结构
- 数据结构课程设计 6 1 彩票系统
- 教学计划编制系统
- 大数(链表、数组)实现
- 自己写的航空订票系统c 版--数据结构
- 数据结构实验魔王语言
- 航空订票系统_数据结构课程设计
- 多项式求和(数据结构C 版)
- 尚观培训linux董亮老师关于数据结构的
- 数据结构 知识点总结
- 华南理工大学数据结构复习提纲二
- 华南理工大学数据结构复习提纲一
- 数据结构用C 写的停车场系统源代码
- 数据结构(河北科技大学)
- 数据结构考前习题 清华大学出版社
- 数据结构课件(北邮)
- 数据结构实验 基于栈的表达式求值
- 数据结构课程设计——图书管理系统
- 成绩管理系统(数据结构)
- 数据结构-最小通信网问题
- 数据结构课程设计同学通讯录系统
- 数据结构课程设计 公园导游图
- 数据结构殷人昆版的课后答案
- 2006年湖北工业大学409数据结构试题
- 数据结构实验-魔王语言-源码加实验报
- 简单计算器的实现(数据结构)
- 简单计算器的实现(数据结构 修正版
- Fundamentals of Data Structure in C
- 北京邮电大学数据结构历年考研真题
评论
共有 条评论