UVA 10815 Andy's First Dictionary【set】】的更多相关文章

题目链接: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…
感觉这道题要比之前几个字符串处理的题目难度要大了一些. 题目大意:给若干行字符串,提取出所有单词并去掉重复的,最后按字典顺序输出. 对于输入大致有两种思路,一种是逐个读入字符,遇到字母的话就放到word里面,直到遇到非字母字符,在word最后放'\0'. 我采用第二种思路,就是用gets()函数逐行读到str字符数组里面,然后逐个把单词提取出来. Count存放的是Dictionary里单词的个数,每提取一个单词,看看Dictionary里有没有该单词,没有的话放到字典里面,并且计数器加1. 由…
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…
原题链接: 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/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…
题意:和上次的cf的ZeptoLab的C一样,是紫书的例题7-11 不过在uva上交的时候,用%I64d交的话是wa,直接cout就好了 #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stack> #include<vector> #include<map> #include<set> #inclu…
题意:给出 n张牌,从上往下编号依次为1到n,当牌的数目至少还剩下2张时,把第一张牌扔掉,然后把新的一张牌放在牌堆的最底部,问最后剩下的那一张牌是哪一张牌. 模拟队列的操作------- #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<vector> #include<queue> using namespace st…
题意:给出n个等距离的村庄,每个村庄要么买酒,要么卖酒,买酒和卖酒的总量相等, 把k个单位的酒从一个村庄运送到相邻的村庄,需要耗费k个单位劳动力,问怎样运送酒使得耗费的劳动力最少 买     卖          买        卖        买 5      -4          1         -3        1 可以从样例来模拟,第一个村庄需要买5桶酒,这5桶酒都是从右边的别的村庄运过来的,第二个村庄需要卖4桶酒, 那么可以这样想,第一个和第二个村庄捆绑在一起的需求量为 a…