题意:输入文本,把不同的单词按照字典序排列。

/*
tolower
功 能: 把字符转换成小写字母,非字母字符不做出处理 头文件
目前在头文件iostream中也可以使用 isalpha 一种函数:判断字符ch是否为英文字母,若为英文字母,返回1。若不是字母,返回0 stringstream,由iostream派生而来,提供读写string的功能。
*/ #include<iostream>
#include<set>
#include<sstream>
#include<cstdio>
#include<string> using namespace std; set<string>dict; int main()
{
// freopen("in.txt","r",stdin);
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); //iostream标准库支持内存中的输入/输出,只要将流与存储在程序内存中的string对象捆绑起来即
while(ss >> buf) dict.insert(buf);
}
for(set<string>::iterator it = dict.begin();it != dict.end(); ++it){
cout<<*it<<"\n";
}
return ;
}

UVA 10815的更多相关文章

  1. UVa 10815 安迪的第一个字典

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

  2. UVA 10815 Andy's First Dictionary (C++ STL map && set )

    原题链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...

  3. UVA 10815 Andy's First Dictionary ---set

    题目链接 题意:输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出.单词不区分大小写. 刘汝佳算法竞赛入门经典(第二版)P112 #include <iostream> ...

  4. UVa 10815 Andy's First Dictionary

    感觉这道题要比之前几个字符串处理的题目难度要大了一些. 题目大意:给若干行字符串,提取出所有单词并去掉重复的,最后按字典顺序输出. 对于输入大致有两种思路,一种是逐个读入字符,遇到字母的话就放到wor ...

  5. UVA 10815 Andy&#39;s First Dictionary(字符处理)

    Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him ...

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

  8. UVA 10815 Andy's First Dictionary【set】

    题目链接:https://vjudge.net/contest/211547#problem/C 题目大意: 输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出,单词不区分大小写 ...

  9. UVA 10815:Andy's First Dictionary(STL)

    题意:给出一段英文,里面包含一些单词,空格和标点,单词不区分大小写,默认都为小写.按照字典序输出这些单词(这些单词不能有重复,字母全部变成小写) stringstream:包含在头文件#include ...

随机推荐

  1. 灰常好的开源项目[c/c++]

    ClibPDF http://cosoft.net.cn http://www2s.biglobe.ne.jp/~Nori/ruby/dist/ClibPDF-ALPHA-20010519.tar.g ...

  2. 开始JavaScript

    将脚本放在那里? 将本可以放在HTML页面上的两个位置:<head>和</head>标签之间(称为头脚本,header script),或者<body>和</ ...

  3. C++Primer 一

    1.vertor和数组的区别: 数组的长度固定.而且程序是无法知道一个给定数组的长度,数组没有获取器容量大小的size操作,也不提供puch_back操作在其中自动添加元素 2.数组定义中的类型可以示 ...

  4. jQuery从无知到无所不知

    说明: 本文以读书笔记的方式整理jQuery的重要知识点,言简意赅,一语中的,删繁就简,引人入胜. 本文先对jQuery强大的功能作一系统的介绍,再详细整理jQuery的选择器.过滤器.DOM操作.事 ...

  5. 开源一个silverlight上的文本编辑器:SlEditor

    控件设置三个状态:编辑.设计.查看. 控件的内容可以打包保存为zip格式,内容可以包含图片等元素(解决了silverlight RichTextBox控件xaml属性无法获取InlineUIConta ...

  6. centos7下安装mantis

    1.环境配置 Web Server:Apache,The web server must support PHP. 数据库:MySQL (or one of its forks, e.g. Maria ...

  7. actionscript 截图功能实现

    由于截图访问的是 外部 rtmp直播流 所以调用BitmapData.draw时 控制台报以下错误: SecurityError: Error #2123: 安全沙箱冲突:BitmapData.dra ...

  8. java中与数据库的连接

    package unitl01; import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet; ...

  9. jquery 操作

    Jquery使用时要引用,引用时放在最前. Jquery: $代表选择器, $(document) ready(function(e){}):找到页面,页面加载完成后执行. JS选取元素操作内容操作属 ...

  10. ZendStudio13 PHP调试环境快速配置

    1.百度ZendStudio13,汉化,破解,注册: 2.安装国产Apache+MySql一键安装环境phpStudy,方便快速  http://www.phpstudy.net/a.php/208. ...