#include<iostream>
#include<string>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
//函数功能 给定一串字符 按空格分割字符串
vector<string> fromstrtointarry(string str) {
stringstream s(str);
string n;
vector<string> res;
while (s >> n) {
res.push_back(n);
}
return res;
}
//函数功能 给定一串字符 按空格分别提取出整数
vector<int> fromstrtointarry(string str) {
stringstream s(str);
int n;
vector<int> res;
while (s >> n) {
res.push_back(n);
}
return res;
}
//按特定字符分割字符串
// s为带分割字符串 v为分割结果vector<string> c为切割字符
void SplitString(const std::string& s, std::vector<std::string>& v, const std::string& c)
{
std::string::size_type pos1, pos2;
pos2 = s.find(c);
pos1 = 0;
while (std::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));
}
//函数功能 string 转 int
int strtoint(string &svalue){
stringstream ss;
ss << svalue;
int ivalue;
ss >> ivalue;
return ivalue;
}
//函数功能 int 转 string
string inttostr(int &ivalue){
stringstream ss;
ss << ivalue;
string svalue;
ss >> svalue;
return svalue;
}
网友评论