UVA-10815
来源:互联网 发布:淘宝美瞳店铺哪个好 编辑:程序博客网 时间:2024/06/05 03:40
题目传送门☞ https://vjudge.net/problem/UVA-10815
我一开始的解法,很简单,过了样例,然后果断wa.
#include <iostream>#include <cstdio>#include <queue>#include <vector>#include <map>#include <set>#include <algorithm>#include <sstream>using namespace std;set<string> se;int main(){ string str, buf; while ( cin >> str ) { int len = str.length(); for (int i = 0; i <= len; i++) { if (isalpha(str[i]) == 0 ) str[i] = ' '; str[i] = tolower(str[i]); } stringstream ss(str); while (ss >> buf) se.insert(buf); } set<string>::iterator it; for(it = se.begin(); it != se.end(); it++) { cout << *it << endl; } return 0;}
//如果文本中有个是 hello*world,这将被分成两个单词,而不是一个单词;
//所以后来我发现,我第一种的错误是hello*world,将被看成一个单词,
//下面是参考了网上的博客,用sstream下的streamstring合理处理了string。
#include <iostream>#include <cstdio>#include <queue>#include <vector>#include <map>#include <set>#include <algorithm>#include <sstream>using namespace std;set<string> se;int main(){ string str, buf; while ( cin >> str ) { int len = str.length(); for (int i = 0; i <= len; i++) { if (isalpha(str[i]) == 0 ) str[i] = ' '; str[i] = tolower(str[i]); } stringstream ss(str); while (ss >> buf) se.insert(buf); } set<string>::iterator it; for(it = se.begin(); it != se.end(); it++) { cout << *it << endl; } return 0;}
0 0
- uva-10815
- uva 10815
- uva 10815
- uva 10815
- uva 10815
- uva-10815
- UVA 10815
- UVa 10815
- UVA 10815
- uva 10815
- uva 10815
- UVA - 10815
- uva 10815
- UVA 10815
- UVa 10815
- UVA - 10815
- UVA-10815
- UVA 10815
- LeetCode 136 Single Number
- iOS开发网络篇—文件下载(暂停和恢复)
- 机器学习 第五天 17/03/31
- 进阶过程之简单工厂模式
- Python-Image 基本的图像处理操作
- UVA-10815
- Algorithm by C/C++ : Callback function
- Android UncaughtExceptionHandler 解决未捕获异常,防止软件报”停止运行“
- Caffe
- Qt2D绘图详解
- Objective-C文件和目录操作,IOS文件操作,NSFileManager使用文件操作
- 开源网站收集
- 分布式--CentOS安装zookeeper(单机版)
- 拷贝函数的选取,极其sizeof()运算符的注意事项及其实例