uva10815 Andy's First Dictionary(字符串的简单处理)
2015-04-04 17:29
387 查看
题目戳这里
题意:
按字典序输出文字段落中出现过的所有单词,出现多次记为一次。
思路:
1.大写换小写。
2.过滤字母以外字符,生成多个单词,将单词插入到set容器中。
3.使用set容器按字典序自动生成所需答案。
ac代码:
题意:
按字典序输出文字段落中出现过的所有单词,出现多次记为一次。
思路:
1.大写换小写。
2.过滤字母以外字符,生成多个单词,将单词插入到set容器中。
3.使用set容器按字典序自动生成所需答案。
ac代码:
[code]/* *Author : Flint_x *Created Time : 2015-04-04 17:02:48 *File name : uva10815.cpp */ #include<iostream> #include<sstream> #include<fstream> #include<vector> #include<list> #include<deque> #include<queue> #include<stack> #include<map> #include<set> #include<bitset> #include<algorithm> #include<cstdio> #include<cstdlib> #include<cstring> #include<cctype> #include<cmath> #include<ctime> #include<iomanip> using namespace std; const double eps(1e-8); typedef long long lint; set<string>dic; int main(){ //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); char c; while(c != EOF){ string word = ""; while(1){ c = getchar(); if((c >= 'A' && c <= 'Z')) c += 32; // cout << c << endl; if((c >= 'a' && c <= 'z') ){ word += c; } else break; } dic.insert(word); } dic.erase(dic.begin()); set<string>::iterator it; for(it = dic.begin();it != dic.end();it ++){ cout << *it << endl; } return 0; }
相关文章推荐
- 南阳oj 400 I'll play a trick on you (细节规律题 简单的字符串处理)
- Group by 自定义函数 连接字符串的简单处理
- python字符串处理简单优化
- 处理PHP字符串的10个简单方法
- C&&C++ 简单 文件处理
- 问题1:java中没有实现这种“byte a = 0xB2 --> String b = “B2””转换的简单实现需要自己实现。 答:自己编写的转换函数,思路将byte的高低4位分开,分别转换为对应的字符然后合成返回的字符串。 java 代码 1.
- 在SQL中参数值超过8000(TEXT类型)的处理方法,以"逗号"分隔的字符串
- 处理PHP字符串的10个简单方法
- 字符串内特殊字符在html_javascript_xml等内使用时的转换 ,"缺少十六进制数字"错误的处理
- PHP处理字符串的10个简单方法
- 截取字符串最后一个字符 && asp textarea 多行数组分割处理
- "将截断字符串或二进制数据。rn语句已终止"提示错误的处理
- PHP字符串处理的10个简单方法
- 使用java 命令运行出现"仅当显式请求注释处理时才接受类名称"的简单处理
- strcat,strcpy,strcmp,strlen4个常用字符串处理函数的数组与指针简单实现方法~
- 俺写的一个简单的字符串处理函数(可能会有用)
- scanf()与sscanf()学习,简单的字符串处理。
- 处理PHP字符串的10个简单方法
- 处理PHP字符串的10个简单方法
- hdu 3973 AC's String 字符串哈希处理 查询子串是否是模式串 可以修改