您的位置:首页 > 其它

uva10815 Andy's First Dictionary(字符串的简单处理)

2015-04-04 17:29 387 查看
题目戳这里

题意:

按字典序输出文字段落中出现过的所有单词,出现多次记为一次。

思路:

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐