单词的提取 include include include include include//按字典序输出

include<stdio.h>

include

include

include//按字典序输出

using namespace std;
vector words;
map<string,bool > dic;
int main()
{
//连续读入字符
string word;char c;
while(scanf("%c",&c)!=EOF)
{
if(c' '||c' ')
{
if(!word.empty()&&!dic[word])
{
words.push_back(word);
dic[word]=true;
word.clear();
}
}
else
{
if(c>='a'&&c<='z')
{
word=word+c;
}
else if(c>='A'&&c<='Z')
{
char nc='a'+c-'A';
word=word+nc;
}
else if(!word.empty()&&!dic[word])
{
words.push_back(word);
dic[word]=true;
word.clear();
}
}
}
sort(words.begin(),words.end());
/*
第一种输出方案
/
for(vector::iterator it=words.begin();it!=words.end();it++)
{
cout<<
it<<endl;
}

/*
第二种输出方案 (适用于c++11)
/
// for(auto it=words.begin();it!=words.end();it++)
// {
// cout<<
it<<endl;
// }

/*
第三种输出方案
*/
// for(int i=0;i<words.size();i++)
// {
// cout<<words.at(i)<<endl;
// }
return 0;
}