资源简介
数据结构上机作业,链表写列车时刻表管理系统,cpp文件
代码片段和文件信息
#include
using namespace std;
template
struct linkNode
{
T TrainNumStartTimeEndTimeStartPointEndPoint;
linkNode *link;
linkNode(linkNode *ptr=NULL)
{
link=ptr;
}
linkNode(const T &item1const T &item2const T &item3const T &item4const T &item5 linkNode *ptr = NULL)
{
TrainNum=item1;
StartTime=item2;
EndTime=item3;
StartPoint=item4;
EndPoint=item5;
link=ptr;
}
};
template
class List
{
protected:
linkNode *first;
public:
List(){first=new linkNode;}
List(const T& x){first=new linkNode (x);}
~List(){makeEmpty();}
void makeEmpty()
{
linkNode *p=new linkNode();
p->link=NULL;
}
int Length()const
{
linkNode *p=first->link;
int count=0;
while(p!=NULL)
{p=p->link;count++;}
return count;
}
linkNode *Search(T x)
{
linkNode *current=first->link;
while(current!=NULL)
if(current->TrainNum==x)break;
else current=current->link;
return current;
}
int Searchloc(T x)
{
int i=0;
linkNode *current=first->link;
while(current!=NULL)
{
i++;
if(current->TrainNum==x)
break;
else current=current->link;
}
return i;
}
linkNode *Locate(int i)
{
if(i<0)return NULL;
linkNode *current=first;
int k=0;
while(current!=NULL&&k {
current=current->link;
k++;
}
return current;
}
bool getData(int iT& x)const
{
if(i<=0)return NULL;
linkNode *current=Locate(i);
if(current==NULL)return false;
else{x=current->data;return true;}
}
void setData(int iT& x)
{
if(i<=0)return;
linkNode *current=Locate(i);
if(current==NULL)return;
else current->data=x;
}
bool Insert(int iT& x1T& x2T& x3T& x4T& x5)
{
linkNode *current=Locate(i);
if(current==NULL)return false;
linkNode *newNode=new linkNode(x1x2x3x4x5);
if(newNode==NULL){cout<<“存储分配错误“< newNode->link=current->link;
current->link=newNode;
return true;
}
bool Delete(int iT& x)
{
linkNode *del*current;
if(i<=1){del=first;first=first->link;}
else
{
current=first;
for(int k=1;k {
if(current==NULL)break;
else current=current->link;
}
if(current==NULL||current->link==NULL)
{
cout<<“无效“< return false;
}
del=current->link;
current->link=del->li
相关资源
- 利用C++哈希表的方法实现电话号码查
- 学校超市选址问题(数据结构C语言版
- 数据结构,迷宫问题C语言版源代码
- DSDEMO-C演示(数据结构C语言版 严蔚敏
- 数据结构 图的遍历源代码
- 数据结构实验源代码集
- 实验报告:数据结构长整数四则运算
- 数据结构教程李春葆第五版书中例题
- 吕鑫vc6c++数据结构视频源码
- 数据结构教程李春葆第五版课后答案
- 链表的基本操作.c
- 链表实现学生管理系统(main.c)
- 李春葆课后习题答案(数据结构教材
- 数据结构1800题 题+答案(全)
- 数据结构(C语言版)ppt课件,清华,
- c++常用游戏算法及数据结构设计
- 数据结构超全面复习导图
- c++ 单链表
- 《Data Structures and Algorithm Analysis in C
- 数据结构C语言版教学笔记严蔚敏
- 数据结构C语言版期末考试试题(有答
- 多功能计算器实现C++代码以及代码详
- C语言数据结构银行客户排队
- C语言实现栈操作
- 简易学生管理系统源码 数据结构 大作
- 数据结构与C语言综合习题集
- 数据结构实验——赫夫曼树相关
- C语言进阶源码---基于graphics实现图书
- 数据结构——C++语言描述 陈慧南
- 广东工业大学数据结构课程设计航空
评论
共有 条评论