https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=835&page=show_problem&problem=1756

输入一个文本,找出所有不同的单词,按字典序从小到大输出,单词不区分大小写。

使用string和set,输入时把所有非字母的字符改成空格,然后利用stringstream得到各个单词并存到set里面(set容器自动去重排序)

 #include<bits/stdc++.h>
using namespace std;
set<string>dict;
int main()
{
string buf,s;
while(cin>>s)
{
for(int i=; i<s.length(); i++)
{
if((s[i]>='a'&&s[i]<='z')||(s[i]>='A'&&s[i]<='Z'))
{
s[i]=tolower(s[i]);
}
else
{
s[i]=' ';
} }
stringstream ss(s);
while(ss>>buf)dict.insert(buf);
}
for(set<string>::iterator it=dict.begin(); it!=dict.end(); it++)
{
cout<<*it<<"\n";
}
return ;
}

uvaoj 1081510815 - Andy's First Dictionary(set应用)的更多相关文章

  1. UVa 10815 Andy's First Dictionary

    感觉这道题要比之前几个字符串处理的题目难度要大了一些. 题目大意:给若干行字符串,提取出所有单词并去掉重复的,最后按字典顺序输出. 对于输入大致有两种思路,一种是逐个读入字符,遇到字母的话就放到wor ...

  2. UVa10815.Andy's First Dictionary

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  3. Problem C: Andy's First Dictionary

    Problem C: Andy’s First DictionaryTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 18 Solved: 5[Submit] ...

  4. 【UVA - 10815】Andy's First Dictionary (set)

    Andy's First Dictionary Description 不提英文了 直接上中文大意吧 XY学长刚刚立下了再不过CET就直播xx的flag,为了不真的开启直播模式,XY学长决定好好学习英 ...

  5. UVA-10815 Andy's First Dictionary (非原创)

    10815 - Andy's First Dictionary Time limit: 3.000 seconds Problem B: Andy's First DictionaryTime lim ...

  6. Andy's First Dictionary

    Description Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy ...

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

    Description Andy, , has a dream - he wants to produce his very own dictionary. This is not an easy t ...

  8. STL语法——集合:set 安迪的第一个字典(Andy's First Dictionary,UVa 10815)

    Description Andy, , has a dream - he wants to produce his very own dictionary. This is not an easy t ...

  9. UVA - 10815 - Andy's First Dictionary STL

    Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him ...

随机推荐

  1. docker-3-常用命令(下)

    importance 1.启动守护式容器 docker run -d 容器名   使用镜像centos:latest以后台模式启动一个容器 docker run -d centos   问题:然后do ...

  2. requireJS使用教程

    一:为什么要使用requireJS? 很久之前,我们所有的JS文件写到一个js文件里面去进行加载,但是当业务越来越复杂的时候,需要分成多个JS文件进行加载,比如在页面中head内分别引入a.js,b. ...

  3. CodeForces - 616C(很有意思的bfs,set,map的使用)

    传送门: http://codeforces.com/problemset/problem/616/C C. The Labyrinth time limit per test 1 second me ...

  4. Xcode7解决VVDocumenter 不能使用的方案

    Xcode7解决VVDocumenter 不能使用的方案 VVDocumenter-Xcode是Xcode上一款快速添加标准注释,并可以自动生成文档的插件.有了VVDocumenter-Xcode,规 ...

  5. Java参数传递对象引用传递失效

    产线问题排查,方法传递对象引用但返回后对象一直为空 原因: null作为参数传递的时候,就不是引用传参了 Java参数引用传递之例外:null 众所周知的是,java中除基本类型外,参数都是引用传递. ...

  6. CSS-自定义变量

    使用背景: 一些常见的例子: 为风格统一而使用颜色变量 一致的组件属性(布局,定位等) 避免代码冗余 *更方便的从CSS向JS传递数据(例如媒体断点) 为什么使用: 以下几点是未来CSS属性的简短说明 ...

  7. eclipse中误删tomcat后,文件都报错,恢复server时无法选择tomcat7.0解决办法

    创建Tomcat v7.0 Server 不能进行下一步. 解决方法: 1.退出 eclipse 2.到[工程目录下]/.metadata/.plugins/org.eclipse.core.runt ...

  8. RCF的简单使用教程以及什么是回调函数

    RCF的使用教程 RCF(Remote Call Framework)是一个使用C++编写的RPC框架,在底层RCF支持多种传输实现方式(transport implementations). 包括T ...

  9. Linux性能检查命令总结[转]

    一些常用的网络.IO.内存监控指令,Linux性能检查命令总结

  10. 异常笔记:Hadoop异常 namenode.NameNode: Encountered exception during format

    00:53:47,977 WARN namenode.NameNode: Encountered exception during format: java.io.IOException: Canno ...