1

# STL之set_uva10815

Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him, as the number of words that he knows is, well, not quite enough. Instead of thinking up all the words himself, he has a briliant idea. From his bookshelf he would pick one of his favourite story books, from which he would copy out all the distinct words. By arranging the words in alphabetical order, he is done! Of course, it is a really time-consuming job, and this is where a computer program is helpful.

You are asked to write a program that lists all the different words in the input text. In this problem, a word is defined as a consecutive sequence of alphabets, in upper and/or lower case. Words with only one letter are also to be considered. Furthermore, your program must be CaSe InSeNsItIvE. For example, words like "Apple", "apple" or "APPLE" must be considered the same.

## Input

The input file is a text with no more than 5000 lines. An input line has at most 200 characters. Input is terminated by EOF.

## Output

Your output should give a list of different words that appears in the input text, one in a line. The words should all be in lower case, sorted in alphabetical order. You can be sure that he number of distinct words in the text does not exceed 5000.

## Sample Input

Adventures in Disneyland

Two blondes were going to Disneyland when they came to a fork in the

So they went home.


## Sample Output

a
blondes
came
disneyland
fork
going
home
in
left
sign
so
the
they
to
two
went
were
when


/*
* Filename:    code.cpp
* Created:     2016-04-15
* Author:        yunlong Wang
*[mail:17744454343@163.com]
* Desciption:  Desciption
*/
<span style="font-size:18px;">#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <bitset>
#include <list>
#include <sstream>
#include <set>
#include <functional>

using namespace std;

#define INT_MAX 1 << 30
#define MAX 100

typedef long long ll;

int n;
set<string>dic;

int main(int argc, char const* argv[])
{
string s,every;
while (cin >> s)                            //用string和用char数组时操作要格外区分
{
for (int i = 0; i < s.length(); i += 1)
{
if (isalpha(s[i]))                  //判断是否为英文字母。。。
{
s[i] = tolower(s[i]);           //变为小写
}
else
{
s[i] = ' ';
}
}
stringstream ss(s);                     //创建一个字符串流
while (ss >> every)                     //读取每个字符串并放入set中
{
dic.insert(every);                  //set有自动排序这一功能
}
}
for (set<string>::iterator i = dic.begin(); i != dic.end(); i++)    //set<string>::iterator为引用，相当于指针.
{
cout << *i << endl;
}
return 0;
}</span>

#### stl的学习：c++ STL

2009年09月07日 537KB 下载

#### 走进STL走进STL走进STL

2011年06月04日 68KB 下载

#### stl源码剖析 stl源码剖析

2010年08月05日 7.03MB 下载

#### STL 例题.RAR

2011年07月21日 1.32MB 下载

#### STL源码剖析

2008年05月07日 5.98MB 下载

#### Effective STL

2010年04月07日 464KB 下载

#### 走近 STL走近 STL走近 STL走近 STL

2011年05月18日 4.09MB 下载

#### stl 电子书两本(C++ STL使用教程,STL编程)

2009年02月03日 1023KB 下载

#### sTL解说 sTL解说 sTL解说 sTL解说 sTL解说 sTL解说

2010年03月09日 16KB 下载

#### STL Source

2009年12月18日 23.48MB 下载