uvaoj 1081510815 - Andy's First Dictionary(set应用)
输入一个文本,找出所有不同的单词,按字典序从小到大输出,单词不区分大小写。
使用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应用)的更多相关文章
- UVa 10815 Andy's First Dictionary
感觉这道题要比之前几个字符串处理的题目难度要大了一些. 题目大意:给若干行字符串,提取出所有单词并去掉重复的,最后按字典顺序输出. 对于输入大致有两种思路,一种是逐个读入字符,遇到字母的话就放到wor ...
- UVa10815.Andy's First Dictionary
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- Problem C: Andy's First Dictionary
Problem C: Andy’s First DictionaryTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 18 Solved: 5[Submit] ...
- 【UVA - 10815】Andy's First Dictionary (set)
Andy's First Dictionary Description 不提英文了 直接上中文大意吧 XY学长刚刚立下了再不过CET就直播xx的flag,为了不真的开启直播模式,XY学长决定好好学习英 ...
- UVA-10815 Andy's First Dictionary (非原创)
10815 - Andy's First Dictionary Time limit: 3.000 seconds Problem B: Andy's First DictionaryTime lim ...
- Andy's First Dictionary
Description Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy ...
- 安迪的第一个字典(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 ...
- 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 ...
- 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 ...
随机推荐
- PHP------面向对象的特性
面向对象的特性 一.面向对象有三大特性: 封装.继承.多态.(非常重要,第一要记住!!!!!!!!!!) 二.封装 封装就是用来做类的,把一个类封装起来.做类不能随便的做.我们做类不能随便去写一个类, ...
- Linux关于scp命令
声明:本文主要转自https://www.2cto.com/os/201503/379474.html scp主要应用场景如下: (1)必要时,每个季度或者每月将数据由这台服务器传输到另外一台,不过前 ...
- 简单说一说对JavaScript原型链的理解
每一个JavaScript对象都和另一个对象相关联,相关联的这个对象就是我们所说的“原型”.每一个对象都会从原型继承属性和方法.有一个特殊的对象没有原型,就是Object,还有一种通过Object.c ...
- Oracle创建表、修改表、删除表、约束条件语法
一. 使用create关键字创建表 --(1)创建新表use 数据库(在那个数据库中建表)create table 表名(字段名1(列名) 数据类型 列的特征,字段名2(列名) 数据类型 列的特征(N ...
- iOS 杂笔-26(苹果禁用热更新)
iOS 杂笔-26(苹果禁用热更新) 苹果爸爸禁用热更新小伙伴们有什么想说的吗? 苹果爸爸禁用热更新小伙伴们有什么想说的吗? 苹果爸爸禁用热更新小伙伴们有什么想说的吗?
- Java并发编程(一)为什么要并发
并发所带来的好处 1. 并发在某些情况(并不是所有情况)下可以带来性能上的提升 1) 提升对CPU的使用效率 提升多核CPU的利用率:一般来说一台主机上的会有多个CPU核心,我们可以创建多个线程,理论 ...
- weex图片加载更多方法loadmore的使用
首先,放一个weex中loadmore使用的demo,可以看一下http://dotwe.org/vue/8dd2a10c69e149ae8971f8298cc8bebf 1.在list标签上添加 @ ...
- 2018 kali linux install tools
1.VM setup https://www.vmware.com/products/workstation-pro/workstation-pro-evaluation.html VMware-Wo ...
- jquery--DOM操作基础
元素的访问 元素属性操作 获取:attr(name):$("#my").attr("src"); 设置:attr(name,value):$("#my ...
- [].slice.call的理解
首先要说明[].slice.call()与Array.prototype.slice.call() 有什么区别? [].slice === Array.prototype.slice true []为 ...