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那点儿事》ETL中的关键技术

    ETL(Extract/Transformation/Load)是BI/DW的核心和灵魂,按照统一的规则集成并提高数据的价值,是负责完成数据从数据源向目标数据仓库转化的过程,是实施数据仓库的重要步骤. ...

  2. Spring Boot Admin的使用

    http://www.jianshu.com/p/e20a5f42a395 ******************************* 上一篇文章中了解了Spring Boot提供的监控接口,例如 ...

  3. Element is not currently visible and so may not be interacted with错误

    用selenium定位时,碰到这种错误的原因: 此种问题的关键是在于用className和id都不唯一所以找不到对象 所以,碰到这种问题就换一种定位方式

  4. redis 持久化 如果 AOF 文件出错了,怎么办?

    服务器可能在程序正在对 AOF 文件进行写入时停机, 如果停机造成了 AOF 文件出错(corrupt), 那么 Redis 在重启时会拒绝载入这个 AOF 文件, 从而确保数据的一致性不会被破坏. ...

  5. 【转】selenium之 定位以及切换frame

    转载自:http://www.voidcn.com/blog/huilan_same/article/p-6155896.html 很多人在用selenium定位页面元素的时候会遇到定位不到的问题,明 ...

  6. php WIN下编译注意问题

    下载VC2012,安装打开CMD 须运行 vcvars32.bat (初始化VC编译环境) 下载PHP WIN编译包:http://windows.php.net/downloads/php-sdk/ ...

  7. preload pic

    http://www.farinspace.com/jquery-image-preload-plugin/

  8. C#窗体 WinForm 对话框,流

    一.对话框 ColorDialog:颜色选择控件 private void button1_Click(object sender, EventArgs e) { //显示颜色选择器 colorDia ...

  9. Unix 初步(一)

    1.Unix文件系统 Unix文件系统有三种文件类型:普通文件.目录文件和设备文件(将外部设备作为一种特殊的文件进行管理,实现输入输出统一而单纯的操作.) 2.Unix的网络功能 TCP/IP 3.r ...

  10. 连接到CentOS(Linux)服务器ssh、mysql缓慢

    现象: 服务器163与服务器164在同一机柜,双绞线直接连接,从办公室或者服务器163去连机服务器164的ssh.mysql均缓慢,让机房人员查了,无果.而164却正常. 最后发现两个机器/etc/r ...