• 大小: 46KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-02
  • 语言: 其他
  • 标签: Dijkstra  

资源简介

利用vs2010实现的数据结构课程设计题目,能够实现包含线路、站点信息的编辑和查询,换乘查询,支持文件数据的输入输出;能够实现二次换乘和时间最短查询。利用无向图的Dijkstra 算法实现查询;--cugxg2017

资源截图

代码片段和文件信息

// 地铁路径查询.cpp : 定义控制台应用程序的入口点。
//
/*
作者:赵赛赛;
学校:中国地质大学(武汉);
班级:201161;
*/

#include “stdafx.h“
#include “iostream“
#include “stdlib.h“
#include“fstream“
#include“string“
#include“assert.h“
#include   
#include   
using namespace std;
//存储同学信息的结构体;
const int maxdist = 1999999999;
typedef struct site
{
string name;
int key;
site *link;
site(){name=““;link=NULL;};
site(string sint k){name=s;link=NULL;key=k;}
site(string ssite*lint k){name=s;link=l;key=k;}
};
class sitegroup
{
public:
 site *top;      //栈顶指针
     sitegroup() : top(NULL) {}    //构造函数;
 sitegroup(string s) : top(NULL) {}    //构造函数;
 void ~linkedstack() { makeempty(); }   //析构函数;
 void push(site *x);
 int count(){int i;site*p=top;for(i=0;p!=NULL;i++)p=p->link;return i;};
 bool pop();    //退栈;
 site* gettop()const; //取栈顶  ;
     bool isempty() const { return top == NULL; }
     void makeempty(); //清空栈的内容;
 bool only(string s)
 {
 site*t=gettop();
 for(int i=0;i  {
 if(t->name==s)return false;
 else t=t->link;
 }
 return true;
 }
 void getdata();
 int getint(string s)
 {
 site *ss=gettop();
 for(int i=0;i  {
 if(ss->name==s)return ss->key;
 ss=ss->link;
 }
 return -1;
 }
 string getname(int s)
 {
 site *ss=gettop();
 for(int i=0;i  {
 if(ss->key==s)return ss->name;
 ss=ss->link;
 }
 return NULL;
 }

}sites;
typedef struct edge{
string prname;//站名;
string lastname;
int length;
int time;
}edge;
struct stacknode//栈节点;
{
edge *data;
stacknode *link;
stacknode(){link=NULL;};
stacknode(edge* dstacknode *next = NULL): data(d) link(next) { }
};
class linkedstack{ //链式栈类定义   
public:
 stacknode *top;
 string name;             //栈顶指针
     linkedstack() : top(NULL)name(“未录入“) {}    //构造函数;
 linkedstack(string s) : top(NULL)name(s) {}    //构造函数;
 void ~linkedstack() { makeempty(); }   //析构函数;
 void push(edge* x);                  //进栈;
 void push(stacknode *x);
 void named(string s){name=s;};
 int count(){int i;stacknode*p=top;for(i=0;p!=NULL;i++)p=p->link;return i;};
 bool pop();    //退栈;
 stacknode* gettop()const; //取栈顶  ;
     bool isempty() const { return top == NULL; }
     void makeempty(); //清空栈的内容;
 string showname(){return name;}
 void print();
};
struct groupnode
{
linkedstack *data;
groupnode*link;
groupnode(linkedstack*pgroupnode*l){data=p;link=l;}
groupnode(){data=NULL;link=NULL;}
};
class groups
{
public:
groupnode*top;
groups(){top=NULL;}
bool isempty(){return top==NULL;}
void push(linkedstack*x){top = new groupnode(xtop);assert(top != NULL);}
bool pop() {if (isempty() == true) return false;groupnode *p = top;top = top->link; delete p;return true;}
groupnode* gettop(){if (isempty() == true) return NULL;return top;}
int count(){int i;groupnode*p=top;for(i=0;p!=NULL;i++)p=p->link;return i;};

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       6189  2017-12-26 17:32  课设三\edge3.txt

     文件      24238  2017-12-27 21:39  课设三\地铁路径查询.cpp

     文件     186880  2017-12-27 21:37  课设三\地铁路径查询.exe

     文件         48  2017-12-27 21:55  课设三\readme.txt

     目录          0  2017-12-27 21:53  课设三

----------- ---------  ---------- -----  ----

               217355                    5


评论

共有 条评论