UVA 10815 -- Andy's First Dictionary

Posted Amysear

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UVA 10815 -- Andy's First Dictionary相关的知识,希望对你有一定的参考价值。

 

sample input

Adventures in Disneyland

Two blondes were going to Disneyland when they came to a fork in the
road. The sign read: "Disneyland Left."

So they went home.

sample output

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

c++ STL -- set和multiset

  通过这道题,学习了一下set和stringstream。

 1 #include<iostream>
 2 #include<string>
 3 #include<set>
 4 #include<sstream>
 5 using namespace std;
 6 
 7 set<string> dict;//string集合
 8 
 9 int main()
10 {
11     string s,buf;
12     while(cin>>s)
13     {
14         for(int i = 0;i<s.length();i++)
15         {//将不是字母的都处理为\' \'
16             if(isalpha(s[i])) s[i] = tolower(s[i]);else s[i] = \' \';
17         }
18         stringstream ss(s);
19         while(ss >> buf) dict.insert(buf);
20     }
21     for(set<string>::iterator it = dict.begin();it != dict.end();it++)
22         cout<<*it<<endl;
23     return 0;
24 }

 

以上是关于UVA 10815 -- Andy's First Dictionary的主要内容,如果未能解决你的问题,请参考以下文章

Uva 10815-Andy&#39;s First Dictionary(串)

Uva 10815.Andy's First Dictionary

UVA - 10815 Andy's First Dictionary

安迪的第一个字典 Andy's First Dictionary, UVa 10815

UVa10815 Andy's First Dictionary (STL)

uva 10815,andy's first ditionary(set,stringstream的简单运用)