📄 setdemo2.cpp
字号:
#include <iostream>
#include <fstream> // for ifstream and ofstream
#include <string>
using namespace std;
#include "worditer.h"
#include "stringset.h"
#include "strutils.h"
#include "prompt.h"
void Print(StringSetIterator& ssi, ostream& output)
{
for(ssi.Init(); ssi.HasMore(); ssi.Next())
{ output << ssi.Current() << endl;
}
}
int main()
{
string filename = PromptString("enter file name: ");
WordStreamIterator wstream;
wstream.Open(filename);
string word;
StringSet wordset;
for(wstream.Init(); wstream.HasMore(); wstream.Next())
{ word = wstream.Current();
ToLower(word);
StripPunc(word);
wordset.insert(word);
}
StringSetIterator ssi(wordset);
Print(ssi,cout);
cout << "# different words = " << wordset.size() << endl;
filename = PromptString("file for output: ");
ofstream output(filename.c_str());
Print(ssi,output);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -