UVA 10815
题意:输入文本,把不同的单词按照字典序排列。
/*
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的更多相关文章
- UVa 10815 安迪的第一个字典
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVA 10815 Andy's First Dictionary (C++ STL map && set )
原题链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...
- UVA 10815 Andy's First Dictionary ---set
题目链接 题意:输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出.单词不区分大小写. 刘汝佳算法竞赛入门经典(第二版)P112 #include <iostream> ...
- UVa 10815 Andy's First Dictionary
感觉这道题要比之前几个字符串处理的题目难度要大了一些. 题目大意:给若干行字符串,提取出所有单词并去掉重复的,最后按字典顺序输出. 对于输入大致有两种思路,一种是逐个读入字符,遇到字母的话就放到wor ...
- UVA 10815 Andy's First Dictionary(字符处理)
Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him ...
- 安迪的第一个字典(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 ...
- 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 ...
- UVA 10815 Andy's First Dictionary【set】
题目链接:https://vjudge.net/contest/211547#problem/C 题目大意: 输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出,单词不区分大小写 ...
- UVA 10815:Andy's First Dictionary(STL)
题意:给出一段英文,里面包含一些单词,空格和标点,单词不区分大小写,默认都为小写.按照字典序输出这些单词(这些单词不能有重复,字母全部变成小写) stringstream:包含在头文件#include ...
随机推荐
- ios 真机调试 could not find Developer Disk Image
同事不小心把iphone测试机升级到了最新系统, 真机调试以前的项目时候不能运行, 提示could not find Developer Disk Image. 原因:缺少最新系统9.3的镜像 解决办 ...
- C++线程池
之前一直在找一个开源的C++线程池库,找了很久也没有找到一个好用的,后来项目需要, 本想自己写一个,但是无意中在github上面找了一个采用boost库实现的threadpool,后来研究 了一下源码 ...
- 帝国cms怎么调用栏目的别名呢?
在世界买家网新模板制作过程中,由于栏目名称比较长,用在标题上没有问题,对seo有利,但是在页面上不希望这么长,简单即可,提过提供了栏目别名,如果能调用就方便了, 请留意下面的修改方法 修改后栏目别名使 ...
- Windows 10 RTM 官方正式版
Windows 10 各版本区别: Windows 10 家庭版:供家庭用户使用Windows 10 专业版:供小型企业使用 在家庭版基础上增加了域账号加入.bitlocker.企业商店等功能Wind ...
- 移动混合开发之android文件管理新建文件和删除文件
今天经过一天超过8小时的实践,有很多CSS上的细节需要注意: 1, /*注意是对before的操作*/ .content ul li .icon-check-empty:before{ display ...
- shell 指定范围随机数抽取
- sqlite的常用语法
sqllite 增删改查创建表的语法 创建表db.execSQL("create table user(_id integer primary key autoincrement,numbe ...
- little tips of painter.drawRect in Qt
一个QImage或QPixmap新建变量时,第一次填充图片时设置的宽高正常(fill),其后的绘制操作(draw)则会在绘制的矩形底边和右边加上painter.pen().width() 在下面代码1 ...
- Uncaught ReferenceError: XXX is not defined
Uncaught ReferenceError: XXX is not defined 这个问题困扰我很久,虽然找到了解决方法,但是还不是很明白. 如下所示:是报错的代码. 如果把它改成下面的形式就可 ...
- 最大流模版 pascal
//最大流模版 ; maxm=; ..maxn] of integer; end; var n,m,max:longint; r:..maxn,..maxn] of longint; g:..maxn ...