c++简单的云南交通咨询系统

本文介绍了一个使用C++编程语言开发的云南交通咨询系统,该系统能够帮助用户查询云南省内的交通信息,包括公路、铁路和航空等。通过简单的命令行界面,用户可以方便地获取所需交通资讯。
在这里插入代码片
#include	<iostream>
#include	 <cstdlib>
#include	 <cstring>
using namespace std;

typedef struct linkNode		
{
   
   
	int data;
	struct linkNode* next;
}Node;          //顶点结构体 

int vNum=0;						//记录点的数量
Node* nodes[30];				//建立邻接表
int status[30];						//记录节点访问状态
int queue[30];						//广度优先遍历时记录遍历序列
int queLen = 0;					//队列长度
int front = 0;						//队列头
int tail = 0;							//队列尾

void push(int element) {
   
   		//入队列操作
	queue[tail] = element;
	tail++;
	queLen++;
}

int pop() {
   
   							//出队列操作
	int res = queue[front];
	front++;
	queLen--;
	return res;
}

void insert(int v1, int v2) {
   
   						//建立邻接表时往链表里插入新的元素
	if (nodes[v1]== NULL) {
   
   									//若该元素没有记录,
		nodes[v1]= (Node*)malloc(sizeof(Node));	//将该元素放入新的空间
		nodes[v1]->data = v2;							//该元素指向“v2”
		nodes[v1]->next = NULL;							//将尾指针置空
	}
	else {
   
   													//若该元素已有记录
		Node* tmp = nodes[v1];								//使用临时指针指向该元素
		while (tmp->next != NULL) {
   
   							//遍历找到以该元素为头结点的链表的尾节点
			tmp = tmp->next;
		}
		tmp->next = (Node*)malloc(sizeof(Node));	
		tmp = tmp->next;
		tmp->data = v2;
		tmp->next = NULL;
	}
}

void graphCreat() {
   
   													//创建邻接表
	cout << "城市的数量:" << endl;
	vNum=16;
	cout<<vNum<<endl;

	cout << "请输入高速路的数量:" << endl;   //管理员登录后输入高速路的数量并且录入高速公路网信息 
	int m = 0;
	cin >> m;

	int x = 0;
	int y = 0; 
	int i;
	cout<<"请录入高速公路信息:"<<endl;
	for (i = 1; i <=m; i++) {
   
   									//重复执行录入操作
		cout << "Line "<<i<<": ";
		cin >> x >> y;
		
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值