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. Exhaustive Search

    Write a program which reads a sequence A of n elements and an integer M, and outputs "yes" ...

  2. SQL Server遍历所有表统计行数

    DECLARE CountTableRecords CURSOR READ_ONLY FOR SELECT sst.name, Schema_name(sst.schema_id) FROM sys. ...

  3. 关闭layer当前弹窗

    一. layer关闭弹出层方法1-1) 先获取某个弹出层的 index   var index = layer.open();   var index = layer.alert();   var i ...

  4. LwIP协议栈开发嵌入式网络的三种方法分析

    LwIP协议栈开发嵌入式网络的三种方法分析   摘要  轻量级的TCP/IP协议栈LwIP,提供了三种应用程序设计方法,且很容易被移植到多任务的操作系统中.本文结合μC/OS-II这一实时操作系统,以 ...

  5. 关于H5 移动端css 文本超出时省略号 失效的问题

    之前写代码的时候遇到一个问题,就是用了下面这段css代码来让文字超出范围隐藏并显示省略号. overflow: hidden; text-overflow: ellipsis; display: -w ...

  6. Oracle中case的第二种用法

    procedure P_GetProVerSingInfo_2018(varFileID in varchar2, p_cr1 out refcontent, p_cr2 out refcontent ...

  7. 使用dbca命令静默卸载数据库

    1)     help查询dbca的选项 su - oracledbca -help dbca [-silent | -progressOnly | -customCreate] {<comma ...

  8. 『C++』Temp_2018_12_13 函数指针

    #include <iostream> #include <string> using namespace std; class Test{ private: string n ...

  9. 断言assert()与调试帮助

    列表内容assert()是一种预处理宏(preprocessor marco),使用一个表达式来作为条件,只在DEBUG模式下才有用. assert(expr); 对expr求值,如果expr为假,则 ...

  10. ;(function($,window,document,undefined){})(jQuery,window,document)

    ;(function($,window,document,undefined){})(jQuery,window,doucment) 1.自调函数(function(){})() 2.好处是不会产生任 ...