感觉这道题要比之前几个字符串处理的题目难度要大了一些. 题目大意:给若干行字符串,提取出所有单词并去掉重复的,最后按字典顺序输出. 对于输入大致有两种思路,一种是逐个读入字符,遇到字母的话就放到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/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 测试数据将输入…
Problem C: Andy’s First DictionaryTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 18 Solved: 5[Submit][Status][Web Board]DescriptionAndy, 8, has a dream – he wants to produce his very own dictionary. This is not an easy task for him, as the number of w…
Problem B: Andy's First Dictionary Time limit: 3 seconds 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…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用stringstream来处理中间的标点. ->直接把他变成一个空格. 然后重新输入进去. set默认的字典序就是升序的了. [错的次数] 在这里输入错的次数 [反思] 在这里输入反思 [代码] #include <bits/stdc++.h> using namespace std; set<string> myset; string s; int main() { //freopen("F:\…
#include<bits/stdc++.h>using namespace std;set<string> dict;int main(){ string s, buf; while(cin >> s) { for(int i = 0;i < s.length();i++) { if(isalpha(s[i])) s[i] = tolower(s[i]); else s[i] = ' '; } stringstream ss(s); while(ss >&…
Description Andy, , 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. Fr…
Description Andy, , 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. Fr…
  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 bo…
题意:给出一段英文,里面包含一些单词,空格和标点,单词不区分大小写,默认都为小写.按照字典序输出这些单词(这些单词不能有重复,字母全部变成小写) stringstream:包含在头文件#include<sstream>中,能将一个字符串分割,用>>输出某些元素 #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include…
参考:https://www.cnblogs.com/yjlblog/p/6947747.html https://blog.csdn.net/hnust_taoshiqian/article/details/43448793 https://blog.csdn.net/liuke19950717/article/details/49450817 https://blog.csdn.net/fanyun_01/article/details/66967710 #include <iostream…
输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出.单 词不区分大小写. 样例输入: Adventures in Disneyland Two blondes were going to Disneyland when they came to a fork in the road. The sign read: "Disneyland Left." So they went home. 样例输出(为了节约篇幅只保留前5行): a adventures blond…
1.set 集合 哦....对了,set有自动按照字典序排序功能..... 声明和插入操作 #include <cstdio> #include <vector> #include <set> using namespace std; int main(){ vector<int> v; ; i < ; i++) { v.push_back(i); v.push_back(i); } set<int> s; s.insert(v.begin…
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1756 题意:很简单,把输入的文本,排序按字典序输出,相当于制作字典. 主要是set和stringstream的运用. 对于stringstream有个简单的程序. #include<iostream> #include<sstream> using namespac…
题意:输入文本,把不同的单词按照字典序排列. /* tolower 功 能: 把字符转换成小写字母,非字母字符不做出处理 头文件 目前在头文件iostream中也可以使用 isalpha 一种函数:判断字符ch是否为英文字母,若为英文字母,返回1.若不是字母,返回0 stringstream,由iostream派生而来,提供读写string的功能. */ #include<iostream> #include<set> #include<sstream> #includ…
水题题目描述就不写了 主要是发现stringstream真的是好用,可以把string绑定到stringstream中,然后就能以空格为分隔符分割出每个单词,听说每次重新创建stringstream开销是巨大的,但是这题两种写法时间上并无太大差别 #include <iostream> #include <cstdio> #include <cstring> #include <sstream> #include <algorithm> #inc…
Description 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. F…
use stringstream Time Limit:3000MS     Memory Limit:0KB Description 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 thin…
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=835&page=show_problem&problem=1756 输入一个文本,找出所有不同的单词,按字典序从小到大输出,单词不区分大小写. 使用string和set,输入时把所有非字母的字符改成空格,然后利用stringstream得到各个单词并存到set里面(set容器自动去重排序) #include<b…
Description 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. F…
这道题主要用到了set容器和stringstream,用起来非常方便,我第一次见识到,觉得十分的炫酷…… 而且,竟然可以将自己写的单词按照字典序排列,真的太酷了. 下面是书上的代码,目前还处于初学状态,所以都是摘抄例题的代码,希望不久之后,我可以用学到的技能自己做出题来. 晚安啦. #include<iostream> #include<string> #include<set> #include<sstream> using namespace std;…
题目链接:Problem C 题意:输入一个文本,找出所有不同的单词,按照字典序从小到大输出,单词不区分大小写. 思路:将字母序列都存为小写,非字母的字符变成空格,然后利用stringstream实现sting对象的自动格式化. note: stringstream对象的使用 #include<sstream> #include<iostream> using namespace std; int main() { string line,word; while(getline(c…