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

题意:很简单,把输入的文本,排序按字典序输出,相当于制作字典。

主要是set和stringstream的运用。

对于stringstream有个简单的程序。

#include<iostream>
#include<sstream>
using namespace std; int main()
{
string s = "12 3 4 5 6";
cout<<s<<endl;
int a = ;
stringstream os;
os << s; //以空格和回车键为分隔符
while(os >> a)
cout<<a<<endl;//输出12\n3\n4\n5\n6\n
return ;
}
#include<cstdio>
#include<iostream>
#include<set>
#include<sstream>
using namespace std; set<string> dict; int main()
{
string s,buf;
while(cin>>s){
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); //分割s,插入set,按从小到大排列
}
//迭代器,认识较浅,记住格式
for(set<string>::iterator it = dict.begin();it != dict.end(); ++it)
cout<<*it<<"\n";
return ;
}

UVa 10815 安迪的第一个字典的更多相关文章

  1. [STL] UVA 10815 安迪的第一个字典 Andy's First Dictionary

    1.set 集合 哦....对了,set有自动按照字典序排序功能..... 声明和插入操作 #include <cstdio> #include <vector> #inclu ...

  2. 安迪的第一个字典(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 ...

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

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

    输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出.单 词不区分大小写. 样例输入: Adventures in Disneyland Two blondes were goin ...

  5. set的运用 例题5-3 安迪的第一个字典(Andy's First Dictionary,Uva 10815)

    #include<bits/stdc++.h>using namespace std;set<string> dict;int main(){ string s, buf; w ...

  6. stl的集合set——安迪的第一个字典(摘)

    set就是数学上的集合——每个元素最多只出现一次,和sort一样,自定义类型也可以构造set,但同样必须定义“小于”运算符 以下代码测试set中无重复元素 #include<iostream&g ...

  7. 安迪的第一个字典(UVa10815)

    题目具体描述见:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_prob ...

  8. 5_3 安迪的第一个字典(UVa10815)<set的使用>

    Andy 是个 8 岁的孩子,他梦想要制作一本他自己的字典. 这并不是一件容易的事,因为他认识的字还不是那么多. 他并不想要自己去想这本字典中该放哪些字,他有个聪明的主意. 就是拿出他最喜欢的一本故事 ...

  9. 安迪的第一个字典 (Andy's First Dictionary,UVa10815)

    题目描述: #include<iostream> #include<string> #include<set> #include<sstream> us ...

随机推荐

  1. 《BI那点儿事》双变量的相关分析——相关系数

    例如,“三国人物是否智力越高,政治就越高”,或是“是否武力越高,统率也越高:准备数据分析环境: SELECT * FROM FactSanguo11 WHERE 姓名 IN ( N'荀彧', N'荀攸 ...

  2. 背景:表A数据误操作,被delete了,恢复。

    SELECT MAX(Scn) FROM Sys.Smon_Scn_Time WHERE Time_Dp < TO_DATE('2015-09-18', 'YYYY/MM/DD') select ...

  3. Java面向对象三大特点之多态

    概念: 多态是同一个行为具有多个不同表现形式或形态的能力. 多态就是同一个接口,使用不同的实例而执行不同操作,如图所示: 多态性是对象多种表现形式的体现,同一个事件发生在不同的对象上会产生不同的结果. ...

  4. pfile 与 spfile

    启动方式与顺序: 启动顺序:dbs 下的 init --> dbs 下的 spfile 如果 pfile 中没有指定 spfile 参数,那么数据库以 pfile 方式启动 如果 pfile 中 ...

  5. Linux shell中运行命令后加上字符“&”的作用

    上午登录服务器编译运行服务端程序的时候,学到了在命令后加上字符“&”后,退出shell,运行的命令可以继续运行.不解原因,并到网上搜索了以下,明白了点! 以下是搜索到的片段: & 放在 ...

  6. laravel 表单验证 正则匹配

    判断url地址 是否为正确格式 控制器中 $this -> validate($request,[ 'linkname' => 'required|max:6|min:2', 'url' ...

  7. 基于讯为4412开发板的Android开发流程

    讯为4412开发板  使用三星2410芯片,基于arm9架构,由于自己电脑硬件的局限,只能跑Android4.0.3系统. 1.Uboot这个直接使用官方镜像烧写就可以了,一般情况不用去重复烧写. 略 ...

  8. VMWARE + CENTOS在windows下配置cocos2d-x android开发环境

    VMWARE + CENTOS在windows配置cocos2d-x android开发环境 之前使用cygwin在windows开发android,后来使用了c++11特性,在cygwin中更新工具 ...

  9. Sql Server 删除所有表

    如果由于外键约束删除table失败,则先删除所有约束: --/第1步**********删除所有表的外键约束*************************/ DECLARE c1 cursor f ...

  10. Objective-C学习笔记-第一天(1)

    .h头文件,用于声明一些公开的属性.方法.头文件一般不会放太多的东西,没必要暴露太多接口,私有和封装. .m主文件,用于实现.h文件中的方法,以及一些其它的方法. -(返回值)方法名参数1名称:(参数 ...