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, as the number of words that he knows is, well, not quite enough. Instead of thinking up all the words himself, he has a briliant idea. From his book…
感觉这道题要比之前几个字符串处理的题目难度要大了一些. 题目大意:给若干行字符串,提取出所有单词并去掉重复的,最后按字典顺序输出. 对于输入大致有两种思路,一种是逐个读入字符,遇到字母的话就放到word里面,直到遇到非字母字符,在word最后放'\0'. 我采用第二种思路,就是用gets()函数逐行读到str字符数组里面,然后逐个把单词提取出来. Count存放的是Dictionary里单词的个数,每提取一个单词,看看Dictionary里有没有该单词,没有的话放到字典里面,并且计数器加1. 由…
原题链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1756 这道题用STL解答还是比较简单的,下面就给大家分享用 set 和 map 的 AC . 解法一(map): #include <iostream> #include <string> #include <map> using names…
题目链接 题意:输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出.单词不区分大小写. 刘汝佳算法竞赛入门经典(第二版)P112 #include <iostream> #include <string> #include <set> #include <sstream> using namespace std; set<string> dict;//string集合 int main() { string s,buf; w…
题目链接:https://vjudge.net/contest/211547#problem/C 题目大意: 输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出,单词不区分大小写. Sample Input Adventures in Disneyland Two blondes were going to Disneyland when they came to a fork in the road. The sign read: "Disneyland Left.&qu…
题目链接:https://vjudge.net/problem/UVA-10815 题意 找出一段文本中的所有单词,以小写形式按照字典序输出. 思路 用空白符替换文本中所有非字母字符后再次读入. 代码 #include <bits/stdc++.h> using namespace std; set<string> st; int main() { string s; while (cin >> s) { for (char &c : s) { if (isal…
Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him, as the number of words that he knows is, well, not quite enough. Instead of thinking up all the words himself, he has a briliant idea. From his book…
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1756 13913607 10815 Andy's First Dictionary Accepted C++ 0.058 2014-07-20 14:02:39 13913568 10815 Andy's First Dictionary Wrong answer C++ 0.17…
10815 - Andy's First Dictionary Time limit: 3.000 seconds Problem B: Andy's First DictionaryTime limit: 3 secondsAndy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him, as the number of words that he know…
Andy's First Dictionary Description 不提英文了 直接上中文大意吧 XY学长刚刚立下了再不过CET就直播xx的flag,为了不真的开启直播模式,XY学长决定好好学习英语.于是他每天都读一篇只包含生词的英语文章,并以自己高达450的智商在一秒钟之内记忆下来. 现在给你一篇XY学长今天要读的文章,请你写一个程序,输出他都学习到了哪些单词.要求:如果文章中有相同的单词,那么仅仅输出一次:而且如果两个单词只有大小写不同,将他们视为相同的单词. Input 测试数据将输入…