- 论坛徽章:
- 0
|
- #include <iostream>
- #include <algorithm>
- #include <iterator>
- #include <vector>
- #include <fstream>
- #include <string>
- using namespace std;
- int main(int argc, char *argv[])
- { ifstream infile("word.txt",ios::in);
- if(!infile) { cout<<"Unable to open the necessary file"<<endl;
- return -1;
- }
- istream_iterator<string> is(infile);
- istream_iterator<string> eof;
- vector<string> text;
- copy(is,eof,back_inserter(text));
- sort(text.begin(),text.end());
- ostream_iterator<string> os(cout,"\n");
- copy(text.begin(),text.end(),os);
-
- return 0;
- }
复制代码
我的文件的内容是afica bango china databus zoo substring hero goto xeon
结果输出的时候就是忽略空格,那么假如要把空格作为字符串的一部分,怎么实现ne?谢谢 |
|