1.通用的头文件util.h:
// file name util.h
// Created by Gabe with CLion.
// 2019/10/2 11:55
#ifndef UTIL_H
#define UTIL_H
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
using namespace std;
#endif //UTIL_H
2.main函数:
#include "util.h"
// 定义测试数据结构体
typedef struct test_data
{
int time_t;
int l_weight;
int r_weight;
} data;
// 字符串分割函数
vector<string> &split(const string &str, const string &delimiters, vector<string> &elems, bool skip_empty = true)
{
string::size_type pos, prev = 0;
while ((pos = str.find_first_of(delimiters, prev)) != string::npos) {
if (pos > prev) {
if (skip_empty && 0 == pos - prev) break;
elems.emplace_back(str, prev, pos - prev);
}