这道题主要用到了set容器和stringstream,用起来非常方便,我第一次见识到,觉得十分的炫酷……

而且,竟然可以将自己写的单词按照字典序排列,真的太酷了。

下面是书上的代码,目前还处于初学状态,所以都是摘抄例题的代码,希望不久之后,我可以用学到的技能自己做出题来。

晚安啦。

#include<iostream>
#include<string>
#include<set>
#include<sstream>
using namespace std; set<string> dict;//string集合 int main(){
string s,buf;
while(cin>>s&&s!="quit"){
for(int i=;i<s.length();i++){
if(isalpha(s[i])) 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 ;
}

UVa10615 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. 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 ...

  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. Andy's First Dictionary

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

  9. C#Dictionary集合的使用

    题目:输入一串字符串字母,比如:Welcome to China,比较每个字母出现的次数,不区分大小写. 解决这道题的方法很多.可能一百个人有一百个思路.当时第一眼看到这个题我的思路是:先将接受的一串 ...

随机推荐

  1. 《JAVA语言》第三节课

    使用递归方式判断某个字串是否是回文( palindrome ). 1. 设计思想 在判断字符串是否是回文的时,采用递归法,首先要分析出重复做的是什么事情,这里是要重复判断两端的字符是不是相等的,直到剩 ...

  2. C++ min函数

    min 是c++标准库头文件中的一个重要的函数.它的功能是一个最小值的函数,比较两个数值的大小,返回他们的之间最小值. #include <algorithm> int a=2; int ...

  3. eclipse Maven Bootstrap 导航栏

    1.在pom.xml添加两个依赖 Bootstrap 依赖和jQuery依赖 代码如下 <!-- https://mvnrepository.com/artifact/org.webjars/b ...

  4. java.lang.ClassNotFoundException: org.apache.commons.dbutils.ResultSetHandle

    原因是这两个地方都得导入dbutils的jar包,一般出错是因为WEB-INF下没有导入包,记得导入,然后buildPath即可

  5. React组件优化

    父组件传值给子组件时只要文本框发生变化就会重新渲染render,我理解我会影响性能,记录下方法用这个生命周期 shouldComponentUpdate 的方法就可以解决子组件重复渲染的问题 shou ...

  6. SGI STL源码stl_vector.h分析

    前言 vector 是最常用的 C++ 容器,其动态扩容的特性是普通数组不具备的,这大大增加了编程的灵活性.虽然平时用 vector 很多,也能基本理解其原理,但无法从深层次理解.直到研读了 vect ...

  7. 【LOJ】#3036. 「JOISC 2019 Day3」指定城市

    LOJ#3036. 「JOISC 2019 Day3」指定城市 一个点的可以dp出来 两个点也可以dp出来 后面的就是在两个点的情况下选一条最长的链加进去,用线段树维护即可 #include < ...

  8. Symfony4框架中单元测试和接口测试中的一些小坑

    前提说明: symfony 版本 4.1.*,使用  composer create-project symfony/website-skeleton  进行安装. 目标:在一个单元测试用例中对当前工 ...

  9. Java 线程控制

    一.线程控制 和线程相关的操作都定义在Thread类中,但在运行时可以获得线程执行环境的信息.比如查看可用的处理器数目(这也行?): public class RunTimeTest { public ...

  10. 【已解决】Field injection is not recommended和Could not autowired. No beans of 'xxx' type found.

    目录 问题 解决办法 备注 问题 在项目中,我们使用Spring的@Autowired注解去引入其他类时有时候阿里的编码规约插件就会提示:"Field injection is not re ...