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项目笔记》创建计算成员

    也可以利用脚本来生成计算成员

  2. 从零开始HTML(三 2016/9/20)

    1.HTML表单 HTML 表单用于搜集不同类型的用户输入.<form> 元素,HTML 表单用于收集用户输入.<form> 元素 ①<input> 元素,< ...

  3. hdu2457DNA repair(ac自动机+dp)

    链接 从开始节点往下走,不能走到病毒节点,如果当前状态与原始串不一样就+1,取一个最小值. #include <iostream> #include<cstdio> #incl ...

  4. Find a point on a 'line' between two Vector3

    Find a point on a 'line' between two Vector3http://forum.unity3d.com/threads/find-a-point-on-a-line- ...

  5. 坑爹的属性,android:descendantFocusability用法简析

    开发中很常见的一个问题,项目中的listview不仅仅是简单的文字,常常需要自己定义listview,自己的Adapter去继承 BaseAdapter,在adapter中按照需求进行编写,问题就出现 ...

  6. SQLServer更新语句要注意

    在SQLServer中 update语句中对于表不能使用别名 eg:update table a set a.column="" where ... 这样在SQLServer中是不 ...

  7. [转]CSS,font-family,常用网页字体

    http://www.zreading.cn/ican/2014/10/css-font-family/ CSS,font-family,好看常用的中文字体 2014-10-14 例1(小米米官网): ...

  8. iOS开发UI篇—Quartz2D使用(信纸条纹)

    iOS开发UI篇—Quartz2D使用(信纸条纹) 一.前导程序 新建一个项目,在主控制器文件中实现以下几行代码,就能轻松的完成图片在视图中的平铺. #import "YYViewContr ...

  9. bzoj 3122: [Sdoi2013]随机数生成器

    #include<cstdio> #include<iostream> #include<map> #include<cmath> #define ll ...

  10. HDU1004 BALLO0N

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...