UVA 10815 (字符串处理)
来源:互联网 发布:剑灵邀请一直网络忙 编辑:程序博客网 时间:2024/05/16 11:25
题目意思:
给你一些文字 包含空格 回车 各种标点
然后你从中找到不同的单词 然后输出就好
思路
string 排序 然后把不同的扔出来
坑点
排序后的第一个点可能是空行 或者乱七八糟的字符什么的 在输出第一个点的时候千万要判断下
我在这里wa无数次 辛酸~~
#include <iostream>#include <cstring>#include <algorithm>#include <ctype.h>#include <cstdio>using namespace std;string S;struct Node{string s;}str[5000005];bool cmp(const Node &a, const Node &b) {return a.s < b.s;}int main(){ int cnt = 0;while (cin >> S) { for (int i = 0; i < S.length(); i ++) { if(isalpha(S[i])) { str[cnt].s += tolower(S[i]); } else cnt ++; } cnt ++;}if(!cnt)return 0;sort(str , str + cnt , cmp);if(isalpha(str[0].s[0]))cout << str[0].s << endl;for (int i = 1; i < cnt; i ++) { if(str[i].s != str[i - 1].s ) cout << str[i].s << endl;}}/*Adventures inTwo blondes were going to Disneyland when they came to a fork in the road. The sign read: "Disneyland Left."Soooooo they went home.*/
阅读全文
0 0
- UVA 10815 (字符串处理)
- UVA 232 字符串处理
- UVa 1585 字符串处理
- UVa 1586 字符串处理
- UVa 232 字符串处理、
- UVA 232 字符串处理
- Palindromes - UVa 401 字符串处理
- UVA 282 - Rename(字符串处理)
- UVA 10082 WERTYU字符串处理
- uva 401 Palindromes(字符串处理)
- uva 10361 Automatic Poetry(字符串处理)
- uva 537 Artificial Intelligence?(字符串处理)
- uva 644 Immediate Decodability(字符串处理)
- uva 409 Excuses, Excuses!(字符串处理)
- uva 502 DEL command(字符串处理)
- uva 1339 Ancient Cipher(字符串处理)
- UVA 156 Ananagrams 模拟+字符串处理
- UVa 494 Kindergarten Counting Game (字符串处理)
- 王小二切饼
- pageEncoding和charset 编码 以及<%@ page contentType="text/html; charset=utf-8"....>作用
- attention 机制入门
- 以开始、中间、最后为基准的递归快排实现
- BZOJ 2442 [Usaco2011 Open]修剪草坪 DP+单调队列优化
- UVA 10815 (字符串处理)
- mysql删除大表更快的drop table办法
- Linux软件安装
- 网络编程和反射--简单讲解
- IDA pro脱壳实战过反调试
- 注册Google Account账号两天仍旧失败后,终于迎来激动人心的时刻!(此电话号码无法用于进行验证)
- GIT 远程仓库:添加远程库、从远程库克隆
- 颜色分类
- Linux下挂载iso文件和配置yum本地源