这道题主要用到了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. 让样式文件,或js文件的相对路径,变成成绝对路径

    添加两行代码即可 <% String path = request.getContextPath(); String basePath = request.getScheme() + " ...

  2. freeRTOS学习8-20

  3. 第10课.c++的新成员

    1.动态内存分配 a.c++中通过new关键字进行动态内存申请 b.c++中的动态内存申请是基于类型进行的 c.delete关键字用于内存释放 2.new关键字与malloc函数的区别 a.new关键 ...

  4. 部署开源mock平台doclever简单叙述

    一.访问官网: http://doclever.cn/controller/index/index.html 二.doclever作用(重点:mock带有转发功能) DOClever是一个可视化接口管 ...

  5. #内存不够,swap来凑# Linux上创建SWAP文件/分区

    转自:https://www.vmvps.com/how-to-create-a-swap-file-on-the-linux-os.html 很久很久以前,电脑的内存是个珍贵东西,于是乎就有了swa ...

  6. NPM安装过程中的一些问题与解决

    1. 安装 vue-cli3后提示 : Package require os(darwin) not compatible with your platform(win32). 上面是因为安装 npm ...

  7. Mac 操作小技巧

    系统版本 MacOs Mojava # 快捷键篇: 1. 打开终端:command+空格,输入terminal:在终端页面,新建终端command + T 2. 打开文件夹:command + T 3 ...

  8. ubuntu 设置静态ip,但显示scope global secondary ens33

    设置静态ip 修改 /etc/network/interfaces 文件 # The loopback network interface auto lo iface lo inet loopback ...

  9. 【LOJ】#3123. 「CTS2019 | CTSC2019」重复

    LOJ3123 60pts 正难则反,熟练转成总方案数减掉每个片段都大于等于s的字典序的方案 按照一般的套路建出kmp上每个点加一个字符的转移边的图(注意这个图开始字母必须是nxt链中下一个相邻的字符 ...

  10. mybatis插入数据返回主键

    原来之前一直用错了... keyProperty是表示将返回的主键设置为该方法参数的对应属性中去,而不是用返回值的形式的去获取.