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

/*
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. 快速加载DXF、DWG格式文件控件ABViewer

    ABViewer是一种高品质,低成本,高效率的多功能设计及工程文档管理应用程序. ABViewer为您提供专业的cad文件浏览和编辑工具. 支持多种格式,如:DWG格式, DXF, DWF, Hewl ...

  2. 开启GZIP(转)

    因为在做一个项目,项目里面服务器主要提供数据,但是数据多了文件就大了,比较浪费流量和时间,我们便用Gzip来处理.我在本机上是apache,服务器上是IIS6.0,用的是php,那么我就在这里分享一下 ...

  3. ANDROID : java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.encodeBase64String in android

    Andriod系统包中现在已经自带加密函数,如果用apache的codec包则会报以上错误,用android.util.Base64以下方法代替org.apache.commons.codec.bin ...

  4. Android -- 关闭AsyncTask(异步任务)

    前面说了如何操作AsyncTask,这篇我们来说一下如何关闭AsyncTask. 有人就问了:为什么要关闭AsyncTask呢?很简单,AsyncTask 是在后台执行耗时操作(获取数据),当你离开当 ...

  5. 搭建TestNG环境( 一)

    一:搭建环境 打开eclipse-->help-->Install New SoftWare,按下图操作:添加http://beust.com/eclipse 验证是否安装成功,file- ...

  6. jpa遇到的 org.hibernate.PersistentObjectException: detached entity passed to persist异常

    jpa遇到的 org.hibernate.PersistentObjectException: detached entity passed to persist异常 发生这个原因是因为我们已经在实体 ...

  7. C语言程序设计第8堂作业

    一.本次课主要内容: 本次课通过以下两个知识点来完成: (1)以数字金字塔为例,介绍函数的另一种形式,即不返回结果的函数.不返回结果的函数在定义.调用.参数传递.函数声明上,思路完全与以前相同,只是函 ...

  8. Material Design使用记录

    出现过的问题记录: 1.Crash on Android 6.0 in RippleView.draw() 解决方法: This has very simple solution. Just down ...

  9. Difference between web server ,web container and application server

    In Java: Web Container or Servlet Container or Servlet Engine : is used to manage the components lik ...

  10. HTTP简介

    HTTP协议是Hyper Text Transfer Protocol(超文本传输协议)的缩写,是用于从万维网(WWW:World Wide Web )服务器传输超文本到本地浏览器的传送协议.. HT ...