暑期集训1:C++STL 例1:UVA-10815

news/2024/7/5 1:57:16

2018学校暑期集训第一天——C++与STL

例一  ——  UVA - 10815 

Andy's First Dictionary

Description

XY学长刚刚立下了再不过CET就直播xx的flag,为了不真的开启直播模式,XY学长决定好好学习英语。于是他每天都读一篇只包含生词的英语文章,并以自己高达450的智商在一秒钟之内记忆下来。

现在给你一篇XY学长今天要读的文章,请你写一个程序,输出他都学习到了哪些单词。
要求:如果文章中有相同的单词,那么仅仅输出一次;而且如果两个单词只有大小写不同,将他们视为相同的单词。

Input

测试数据将输入一篇文章。不超过5000行,每一行最多200个字符,并以EOF结束。

Output

按照字典序输出他学到的单词,每行输出一个单词,输出单词时所有的字母全部小写。 
数据保证最多有5000个需要输出的单词。

Sample Input

样例输入①

Adventures in DisneylandTwo blondes were going to Disneyland when they came to a fork in the
road. The sign read: "Disneyland Left."So they went home.

Sample Output

a
adventures
blondes
came
disneyland
fork
going
home
in
left
read
road
sign
so
the
they
to
two
went
were
when

Hint

输入可能包含标点符号,但标点符号显然不能算作单词的一部分。

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
using namespace std;int main(void) 
{string word;set<string> dict;while (cin >> word) {string cur = "";for (int i = 0; i < word.length(); i++) {if (isalpha(word[i]))cur += tolower(word[i]);else if (cur != "") {dict.insert(cur);cur = "";}}if (cur != "") dict.insert(cur);}for (set<string>::iterator it = dict.begin(); it != dict.end(); it++)cout << *it << endl;return 0;
}

注:此题主要练习STL的set


http://lihuaxi.xjx100.cn/news/247415.html

相关文章

前端工程师成长之多读好书

1 引言 乱七八糟的书看了很多&#xff0c;有一本讲JavaScript的印象特别深开篇说的是"JavaScript是Java的脚本语言"&#xff0c;但还是看完了&#xff0c;最后忘了书名。 下面列的这些都是看过后至少记得起书名的&#xff0c;也有部分是经常看的书&#xff0c;一起列…

Linux中V4L2使用

查看USB摄像头参数 查看所有参数 v4l2-ctl -d /dev/video0 --all 查看所有的摄像头 ls /dev/video* 查看不同参数的具体意思 v4l2-ctl help 参考文献 https://www.cnblogs.com/emouse/archive/2013/03/04/2943243.html] 和菜鸟一起学linux之V4L2摄像头应用流程_东月…

linux tune2fs简解(每日一令之五)

1:命令简介Linux下的文件检测命令&#xff0c;且可以自行定义自检周期2&#xff1a;用法[rootuyhd000225 ~]# tune2fs --help tune2fs 1.39 (29-May-2006) tune2fs&#xff1a;无效选项 -- - Usage: tune2fs [-c max_mounts_count] [-e errors_behavior] [-g group][-i interva…

暑期集训2:ACM基础算法 例1:POJ-1064

2018学校暑期集训第二天——ACM基础算法 例一 —— POJ - 1064 Cable master Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever…

实验: VMware使用快照间接备份原始VMDK文件

资料上看的使用快照备份运行着的虚拟机 当虚拟机开着时&#xff0c;快照提供了一个备份原始 VMDK 文件的好办法。所有的写入操作在原始文件上暂停了&#xff0c;因此&#xff0c;复制它在另一个存储卷很安全。这就是像 VMware Consolidated Backup 和 Vizioncore 的 vRanger…

Linux学习笔记8——bash基本概念

一个操作系统的组成中&#xff0c;shell是与用户最接近的部分shell&#xff1a;外壳&#xff0c;也是一种程序GUI&#xff1a;Gnome&#xff0c;KDE,XfaceCLI&#xff1a;sh&#xff0c;csh&#xff0c;ksh&#xff0c;bash&#xff0c;tcsh&#xff0c;zshLinux中大多使用bash…

Latex公式

1. LaTex的数学公式基本规则 1.1. 转义 以下几个字符: # $ % & ~ _ ^ \ { }有特殊意义&#xff0c;需要表示这些字符时&#xff0c;需要转义&#xff0c;即在每个字符前加上\&#xff08;转义字符的具体含义下面会解释&#xff09; \boxed命令给公式加一个方框。\fbox具有…

暑期集训2:ACM基础算法 例2:POJ-2456

2018学校暑期集训第二天——ACM基础算法 例二 —— POJ - 2456 Aggressive cows Farmer John has built a new long barn, with N (2 < N < 100,000) stalls. The stalls are located along a straight line at positions x1,...,xN (0 < xi < 1,000,000,000…