资源简介
2019华为软件精英挑战赛C++源码,主要是实现了类的定义与数据的读取。
代码片段和文件信息
#include
#include
#include
#include
#include
using namespace std;
class road{
public:
int id;
int length;
int speed;
int channel;
int fromid;
int toid;
int isDuplex;
void display()
{
cout< }
};
class car{
public:
int id;
int fromid;
int toid;
int speed;
int planTime;
void display()
{
cout< }
};
class cross{
public:
int id;
vector roadid;
void display()
{
cout< for(int i=0;i {
cout<<“ “< }
cout< }
};
void SplitString(const string& s vector& v const string& c)
{
string::size_type pos1 pos2;
pos2 = s.find(c);
pos1 = 0;
while(string::npos != pos2)
{
v.push_back(s.substr(pos1 pos2-pos1));
pos1 = pos2 + c.size();
pos2 = s.find(c pos1);
}
if(pos1 != s.length())
v.push_back(s.substr(pos1));
}
void str2car(vector sscar &car)
{
stringstream sstr;
sstr< sstr>>car.id;
sstr.clear();
sstr< sstr>>car.fromid;
sstr.clear();
sstr< sstr>>car.toid;
sstr.clear();
sstr< sstr>>car.speed;
sstr.clear();
sstr< sstr>>car.planTime;
}
void str2road(vector ssroad &road)
{
stringstream sstr;
sstr< sstr>>road.id;
sstr.clear();
sstr< sstr>>road.length;
sstr.clear();
sstr< sstr>>road.speed;
sstr.clear();
sstr< sstr>>road.channel;
sstr.clear();
sstr< sstr>>road.fromid;
sstr.clear();
sstr< sstr>>road.toid;
sstr.clear();
sstr< sstr>>road.isDuplex;
}
void str2cross(vector sscross &cross)
{
stringstream sstr;
sstr< sstr>>cross.id;
sstr.clear();
for(int i=1;i {
sstr< int _roadid;
sstr>>_roadid;
sstr.clear();
cross.roadid.push_back(_roadid);
}
}
int main(int argc char *argv[])
{
std::cout << “Begin“ << std::endl;
// if(argc < 5){
std::cout << “please input args: carPath roadPath crossPath answerPath“ << std::endl;
// exit(1);
// }
// std::string carPath(argv[1]);
// std::string roadPath(argv[2]);
// std::string crossPath(argv[3]);
// std::string answerPath(argv[4]);
string carPath(“C:\\Users\\Administrator\\Desktop\\华为精英挑战赛\\code\\SD
- 上一篇:小波变换C语言实现代码
- 下一篇:新国都系列改SN号软件+教程
评论
共有 条评论