C++
split函数:
#include <iostream>
#include <vector>
#include <string>
#include <boost/algorithm/string.hpp>
int main()
{
std::string str = "1-56-89-52-41-56 ";
std::vector <std::string> result;
boost::algorithm::split(result, str, boost::algorithm::is_any_of( "- "));
for(size_t i = 0; i < result.size(); ++i)
{
std::cout < <result[i] < <std::endl;
}
}
运行结果:
1
56
89
52
41
56
此方法应该是返回接近参数的int或long或什么什么,API上说是通过把参数加上1/2,再将该结果舍入。那么,
int x = (int) Math.round(-24.8);
int y = (int) Math.round(24.45);
x=-25,y=24
这是咋算的啊?!