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

/*
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. webdriver无法打开firefox

    1.执行webdriver.firefox()报错,提示: WebDriverException: Message: "Can't load the profile. Profile Dir ...

  2. Java 设计模式学习

    看完headfirst设计模式,简单总结一下. 写在最前面:设计模式的关心的问题为"弹性.易于维护.易于扩展",通过对模式的应用,让自己的代码能够得到良好的可塑性.但是个人认为不能 ...

  3. 内核input子系统分析

    打开/driver/input/input.c 这就是input代码的核心 找到 static int __init input_init(void) { err = class_register(& ...

  4. c# UrlEncode,UrlDecode

    用 C#  winform  处理 utf-8,gb2312编码转换方法 首先,在项目属性 的  应用程序——目标框架中,选择 .NET Framework 4 然后再添加引用——.NET 中选择  ...

  5. opacity与RGBA透明的区别

    为什么不使用opacityCSS3 还允许通过opacity 声明来设置元素的透明度.该透明度的值也是一个介于0 到1 之间的小数(如将opacity 设置为0.1 表示为10%透明).但是这种透明度 ...

  6. putty连接报NetWork error:connection refused

    首先通过物理终端进入到linux上,手工检查ssh发现没运行 /etc/init.d/sshd status 使用rpm -V 命令可检查到ssh的软件包正常 /rpm -V openssh-serv ...

  7. Adaboost 算法

    一 Boosting 算法的起源 boost 算法系列的起源来自于PAC Learnability(PAC 可学习性).这套理论主要研究的是什么时候一个问题是可被学习的,当然也会探讨针对可学习的问题的 ...

  8. 搭建java web开发环境、使用eclipse编写第一个java web程序

    开发工具:eclipse-jee-juno-SR2-win32-x86_64(请自行官网下载) 使用服务器:apache-tomcat-7.0.35-windows-x64(请自行官网下载) 打开 e ...

  9. UIkit框架之uiUIapplication

    1.继承链:uiresponder:NSObject 2.使用 sharedApplication方法来存取对象 3.这个类可以遵守协议是UIApplicationDelegate 4.获取app的实 ...

  10. BeautifulSoup-find,findAll

    BeautifulSoup的主要函数使用 from bs4 import BeautifulSouphtml = """<html><head>& ...