📄 common.h
字号:
#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>
using namespace std;
typedef char ElemType[6];
#define maxnode 5000;
#define infinity 1000000;
ElemType vtail,vhead;//要查询的起点和终点,作为全局变量
bool ev[600][100],fv[600][100];//e[i][j]为线路i会进入站点j,f[i][j]为线路i会从站点j出来
void namel(ElemType linename,int busline)
{
int i,k;
k=busline;
for(i=3;i>0;i--)
{
linename[i]=k%10+'0';
k/=10;
}
linename[0]='L';
linename[4]='\0';
}
int change(ElemType str)//将弧名转为相应的数字
{
return (str[1]-'0')*100+(str[2]-'0')*10+(str[3]-'0');
}
int changel(ElemType str)//将站点名转为相应的数字
{
return (str[1]-'0')*1000+(str[2]-'0')*100+(str[3]-'0')*10+(str[4]-'0');
}
int checkarcname(ElemType str)//检查输入的弧名是否正确:"L+三位数字",正确就返回1,否则0
{
if(strlen(str)<4||strlen(str)>4)return 0;
if(str[0]=='L')
if(48<=str[1]<=57)
if(48<=str[2]<=57)
if(48<=str[3]<=57)
return 1;
return 0;
}
void names(ElemType s,int n)//给公交站点命名
{
int i,n1;
n1=n;
s[0]='S';
for(i=4;i>0;i--)
{
s[i]=n1%10+'0';
n1/=10;
}
s[5]='\0';
}
int num(int fasttime[5],int time,int count)
{
//看time在fasttime数组中是第几快的,返回数组中的序号。
//如果不能入前五快,返回-1。
//如果count没有5个,则前count快
int lowi,count1,i;
count1=count;
if(count1>5)count1=5;//最多前5快
lowi=0;
for(i=1;i<count1;i++)//找当前最慢的一个比较
if(fasttime[lowi]<fasttime[i])lowi=i;
if(fasttime[lowi]>time){fasttime[lowi]=time; return lowi;}
return -1;
}
int num1(int fasttime[5],int time,int count)
{
//看time在fasttime数组中是第几快的,返回数组中的序号。
//如果不能入前3快,返回-1。
//如果count没有3个,则前count快
int lowi,count1,i;
count1=count;
if(count1>3)count1=3;//最多前3快
lowi=0;
for(i=1;i<count1;i++)//找当前最慢的一个比较
if(fasttime[lowi]<fasttime[i])lowi=i;
if(fasttime[lowi]>time){fasttime[lowi]=time; return lowi;}
return -1;
}
int judgemoney(int sta,bool flag) //看是分段计价还是单一票制,分段为true
{
if(!flag)return 1;//单一票制
else if(1<=sta&&sta<=20)return 1;
else if(21<=sta&&sta<=40)return 2;
else return 3;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -