这道题主要用到了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. 【VS开发】组播(多播)的C程序实战

    每个人都有不同的认知规律和习惯, 有的人喜欢搞一套严密的大理论, 论述起来滔滔不绝, 不管自己懂不懂, 反正读者/听者是没搞懂. 有的人喜欢从实践出发, 没看到代码, 不运行一下, 不看到结果, 就不 ...

  2. 【C/C++开发】【Java开发】JNI的替代者—使用JNA访问Java外部功能接口

    JNI的替代者-使用JNA访问Java外部功能接口 1. JNA简单介绍 先说JNI(Java Native Interface)吧,有过不同语言间通信经历的一般都知道,它允许Java代码和其他语言( ...

  3. 通过火狐谋智查询API

    谋智中文版网址 https://developer.mozilla.org 示例 site: developer.mozilla.org window 通过百度高级用法查API site: 网址 搜索 ...

  4. Angular5 自定义scrollbar样式之 ngx-perfect-scollbar

    版本 angular 5.0 ngx-perfect-scrollbar ^5.3.5 为什么不用 ngx-perfect-scrollbar 最新的版本 v7 呢? 因为它报错啊!!! 每次init ...

  5. Linux下查看文件编码及批量修改编码

    查看文件编码在Linux中查看文件编码可以通过以下几种方式:1.在Vim中可以直接查看文件编码:set fileencoding即可显示文件编码格式.如果你只是想查看其它编码格式的文件或者想解决用Vi ...

  6. 第八周课程总结&实验报告(六)

    第八周课程总结 启动多线程售票(上课老师说要加入作业的部分) public class TestDemo { public static void main(StringD args) throws ...

  7. 阿里redis

    参考: 连接: https://help.aliyun.com/document_detail/43848.html?spm=a2c4g.11186623.2.29.295542efrNOQy0 同R ...

  8. [转帖]传输层安全协议TLS 1.3 RFC 8446使互联网更快、更安全

    传输层安全协议TLS 1.3 RFC 8446使互联网更快.更安全 2018-08-12 11:38:19作者:LINUX人稿源:开源社区 https://ywnz.com/linuxyffq/261 ...

  9. redis 事务 事务机制详解 MULTI、EXEC、DISCARD、WATCH

    1. Redis服务端是个单线程的架构,不同的Client虽然看似可以同时保持连接,但发出去的命令是序列化执行的,这在通常的数据库理论下是最高级别的隔离2. 用MULTI/EXEC 来把多个命令组装成 ...

  10. 句子反转——牛客刷题(java)

    题目描述: 给定一个句子(只包含字母和空格), 将句子中的单词位置反转,单词用空格分割, 单词之间只有一个空格,前后没有空格. 比如: (1) “hello xiao mi”-> “mi xia ...