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

输入一个文本,找出所有不同的单词,按字典序从小到大输出,单词不区分大小写。

使用string和set,输入时把所有非字母的字符改成空格,然后利用stringstream得到各个单词并存到set里面(set容器自动去重排序)

 #include<bits/stdc++.h>
using namespace std;
set<string>dict;
int main()
{
string buf,s;
while(cin>>s)
{
for(int i=; i<s.length(); i++)
{
if((s[i]>='a'&&s[i]<='z')||(s[i]>='A'&&s[i]<='Z'))
{
s[i]=tolower(s[i]);
}
else
{
s[i]=' ';
} }
stringstream ss(s);
while(ss>>buf)dict.insert(buf);
}
for(set<string>::iterator it=dict.begin(); it!=dict.end(); it++)
{
cout<<*it<<"\n";
}
return ;
}

uvaoj 1081510815 - Andy's First Dictionary(set应用)的更多相关文章

  1. UVa 10815 Andy's First Dictionary

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

  2. UVa10815.Andy's First Dictionary

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  3. Problem C: Andy's First Dictionary

    Problem C: Andy’s First DictionaryTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 18 Solved: 5[Submit] ...

  4. 【UVA - 10815】Andy's First Dictionary (set)

    Andy's First Dictionary Description 不提英文了 直接上中文大意吧 XY学长刚刚立下了再不过CET就直播xx的flag,为了不真的开启直播模式,XY学长决定好好学习英 ...

  5. UVA-10815 Andy's First Dictionary (非原创)

    10815 - Andy's First Dictionary Time limit: 3.000 seconds Problem B: Andy's First DictionaryTime lim ...

  6. Andy's First Dictionary

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

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

  9. UVA - 10815 - Andy's First Dictionary STL

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

随机推荐

  1. struts2不同版本在核心filter在web.xml中的配置

    FilterDispatcher是struts2.0.x到2.1.2版本的核心过滤器.配置如下: <filter> <filter-name>struts2</filte ...

  2. logback配置详解和使用

    最近知道一种打印日志的新方法,在此做一下学习总结. 转自:行走在云端的愚公 https://www.cnblogs.com/warking/p/5710303.html 一.logback的介绍   ...

  3. [转]MFC子线程更改图像数据后更新主窗口图像显示方法

    程序思路是由外部的输入输出控制卡发出采集图像信号,之后相机采集图像得到图像数据指针,接收图像数据指针创建成图像最后显示到MFC对话框应用程序的Picture Control控件上,同时,为了标定相机位 ...

  4. 以ADO形式操作mysql数据库

    首先得需要一个连接mysql的helper类: public class MySqlHelper { #region [ Connection ] public static string conne ...

  5. iOS8以后UIAlertView和UIActionSheet两种alert页面都将通过UIAlertController来创建

    1. Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated. ...

  6. 如何不使用 submit 按钮来提交表单?

      如果我们不想用 submit 按钮来提交表单,我们也可以用超链接来提交,我们可以这样写代码: <a href=”javascript: document.myform.submit ();” ...

  7. 常见的springmvc、SpringBoot的注解

    springMvc的常用注解 : @Controller :用于标记在一个类上,使用它标记的类就是一个springmcv Controller对象,分发处理器将会扫描使用了该注解 的类的方法,并检测该 ...

  8. hibernateDAO层基本的增删改查

    完整的学习项目放在了我的github上,是一个半成品的在线音乐网站. hibernate版本1.4 下面是userDAO 即对user表进行增删改查 package DAO; import java. ...

  9. php中的引用

    $var1 = 'zhuchunyu'; $var2 = ""; function foo($vaa){ global $var1,$var2; if (!$vaa){ $var2 ...

  10. 使用 jTessBoxEditor 生成 tesseract-orc 的字典

    本文使用图片方式记录使用 jTessBoxEditor 一站式生成自动文件的方式 首先感谢 Tesseract OCR 讨论群 389402579 的管理员[创世倾城 QQ:457606663] 的帮 ...