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

/*
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. Android ShapeDrawable

    今天做项目碰到一个这样的情况,就是颜色指示框,用的是正方形边框是黑色的,里面填充颜色,颜色值是动态的,为了解决这个问题,查了好多资料,终于找到解决的方法,利用ShapeDrawable,我们自定义一个 ...

  2. C# WebBrowser控件使用教程与技巧收集

    常用的方法 Navigate(string urlString):浏览urlString表示的网址 Navigate(System.Uri url):浏览url表示的网址 Navigate(strin ...

  3. 前端和后台对时间数值的增减操作(JavaScript和C#两种方法)

    最近在做一个视频回放项目,记录下一点总结. 应用背景: 假设有一个门禁系统记录着门禁的人员进出刷卡信息,门禁装有视频录像设备,现在要根据人员的刷卡时间调出其刷卡时间点前后一段时间的录像.关于视频回放部 ...

  4. ueditor工具栏更改按钮的默认操作

    ueditor 上的 image 按钮,默认有一个图片选择工具. 但是我想把他去掉,用上自己写的图片选择功能. 原来使用cleditor 是可以给按钮自定义一个函数.但是在ueditor就没有找到可以 ...

  5. windows 开机启动 CassiniDev(IIS替代软件)

    CassiniDev(IIS替代软件) 使用asp.net的时候,要部署一个iis,或者部署iis express,有时候你嫌麻烦, 这是一个替代品. 功能完全的. 下载地址:http://cassi ...

  6. Xcode清除缓存、清理多余证书

    Xcode清除缓存.清理多余证书 1.删除Xcode中多余的证书provisioning profile 手动删除: Xcode6 provisioning profile path: ~/Libra ...

  7. MongoDB学习

    最近在学习,参考一线码农的教程 http://www.cnblogs.com/huangxincheng/category/355399.html

  8. vector容器使用和assert断言关键字

    C++里面的容器是个比较复杂的东西,我这篇只说vector容器怎么使用,详细的网搜. vector模板类其实是一个动态数组,跟自己用new关键字创建数组一样,只不过vector会自动帮我们用new和d ...

  9. mysqlnd cannot connect 连接错误处理方法

    mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administra ...

  10. Why jsp?

    Before the JSP come into the world . The CGI and servlet took the responsibility of generating dynam ...