首页 > 其它 > 题目详情
C++中split怎么定义啊?#include #include #include #include #include
题目内容:
C++中split怎么定义啊?
#include
#include
#include
#include
#include "split.h"
using std::cin; using std::cout;
using std::endl; using std::getline;
using std::istream; using std::string;
using std::vector; using std::map;
map
xref(istream& in,
vector find_words(const string&) = split)
{
string line;
int line_number = 0;
map ret;
while (getline(in,line)) {
++line_number;
vector words = find_words(line);
#ifdef _MSC_VER
for (std::vector::const_iterator it = words.begin();
#else
for (vector::const_iterator it = words.begin();
#endif
it = words.end(); ++it)
ret[*it].push_back(line_number);
}
return ret;
}
int main()
{
map ret = xref(cin);
#ifdef _MSC_VER
for (std::map::const_iterator it = ret.begin();
#else
for (map::const_iterator it = ret.begin();
#endif
it = ret.end(); ++it) {
cout first second.begin();
#else
vector::const_iterator line_it = it->second.begin();
#endif
cout second.end()) {
cout优质解答
split好像是list容器所特有的啊.
你想干什么呢?
哦,算了我没看清楚题.
你有spih.h这个文件吗?
#include
#include
#include
#include
#include "split.h"
using std::cin; using std::cout;
using std::endl; using std::getline;
using std::istream; using std::string;
using std::vector; using std::map;
map
xref(istream& in,
vector find_words(const string&) = split)
{
string line;
int line_number = 0;
map ret;
while (getline(in,line)) {
++line_number;
vector words = find_words(line);
#ifdef _MSC_VER
for (std::vector::const_iterator it = words.begin();
#else
for (vector::const_iterator it = words.begin();
#endif
it = words.end(); ++it)
ret[*it].push_back(line_number);
}
return ret;
}
int main()
{
map ret = xref(cin);
#ifdef _MSC_VER
for (std::map::const_iterator it = ret.begin();
#else
for (map::const_iterator it = ret.begin();
#endif
it = ret.end(); ++it) {
cout first second.begin();
#else
vector::const_iterator line_it = it->second.begin();
#endif
cout second.end()) {
cout
优质解答
你想干什么呢?
哦,算了我没看清楚题.
你有spih.h这个文件吗?
本题链接: