原题链接:

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 namespace std;
map<string, char> mmp; int main(void)
{
int i, idex = 0;
char ch, str[200]; while (ch = getchar()) {
if (ch == EOF) break;
if (isupper(ch)) ch = tolower(ch);
if (islower(ch)) str[idex++] = ch;
else {
str[idex++] = '\0';
if (idex > 1) mmp[str] = 1;
idex = 0;
}
} for (map<string, char>::iterator i = mmp.begin(); i != mmp.end(); i++)
puts(i -> first.c_str()); return 0;
}

解法二(set):

#include <iostream>
#include <sstream>
#include <string>
#include <set> using namespace std;
set<string> se;
string x, y; int main(void)
{
while (cin >> x) {
for (int i = 0; i < x.length(); i++) {
if (isalpha(x[i]))
x[i] = tolower(x[i]);
else x[i] = ' ';
} stringstream ss(x);//文件流
while (ss >> y) se.insert(y);
} for (set<string>::iterator it = se.begin(); it != se.end(); it++)
cout << *it << '\n'; return 0;
}

最新文章

  1. canvas小结
  2. 体验了微信小程序,发现安卓用户终于把果粉“碾压”了一次
  3. Winform在线更新
  4. 数据库 PSU,SPU(CPU),Bundle Patches 和 Patchsets 补丁号码快速参考 (文档 ID 1922396.1)
  5. Splay伸展树学习笔记
  6. Alcatraz的安装和使用
  7. jq tab
  8. SQL backup&amp;restore
  9. TKinter布局之grid 网格布局
  10. LA 3704 (矩阵快速幂 循环矩阵) Cellular Automaton
  11. website
  12. jQuery学习目录
  13. 【转载】[ORACLE]详解not in与not exists的区别与用法
  14. 使用SVM对多类多维数据进行分类
  15. url获取整理
  16. 一次HTTP请求响应涉及了哪些?
  17. 小程序支持打开APP
  18. webvtt字幕转srt字幕的python程序(附改名程序)
  19. Java拦截器+注解搭配使用
  20. react-router 从 v2/v3 to v4 迁移(翻译)

热门文章

  1. &lt;转&gt;单机版搭建Hadoop环境
  2. how2heap libc2.31学习
  3. Sentinel-Go 源码系列(三)滑动时间窗口算法的工程实现
  4. MVC三种分页方法
  5. ftp:500 Illegal PORT command. 425
  6. C# 金额数字转中文的方法
  7. FastAPI(六十五)实战开发《在线课程学习系统》基础架构的搭建
  8. 再谈多线程模型之生产者消费者(多生产者和单一消费者 )(c++11实现)
  9. 【LeetCode】1020. Partition Array Into Three Parts With Equal Sum 解题报告(Python)
  10. 【LeetCode】79. Word Search 解题报告(Python & C++)