zoukankan      html  css  js  c++  java
  • UVA 10815:Andy's First Dictionary(STL)

    题意:给出一段英文,里面包含一些单词,空格和标点,单词不区分大小写,默认都为小写。按照字典序输出这些单词(这些单词不能有重复,字母全部变成小写)

    stringstream:包含在头文件#include<sstream>中,能将一个字符串分割,用>>输出某些元素

    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    #include <math.h>
    #include <limits.h>
    #include <map>
    #include <stack>
    #include <queue>
    #include <vector>
    #include <set>
    #include <string>
    #include <sstream>
    #define ll long long
    #define ms(a) memset(a,0,sizeof(a))
    #define pi acos(-1.0)
    #define INF 0x3f3f3f3f
    const double E=exp(1);
    const int maxn=1e6+10;
    using namespace std;
    int main(int argc, char const *argv[])
    {
    	ios::sync_with_stdio(false);
    	set<string>se;
    	string ci;
    	string danci;
    	while(cin>>ci)
    	{
    		for(int i=0;i!=ci.length();i++)
    		{
    			if(isalpha(ci[i]))
    				ci[i]=tolower(ci[i]);
    			else
    				ci[i]=' ';
    		}
    		stringstream ch(ci);
    		while(ch>>danci)
    			se.insert(danci);
    	}
    	set<string>::iterator it;
    	for(it=se.begin();it!=se.end();it++)
    		cout<<*it<<endl;
    	return 0;
    }
  • 相关阅读:
    YII框架学习(二)
    YII框架学习(一)
    valid number 判断字符串是否为有效数字
    leetcode Add Binary
    leetcode Minimum Path Sum
    leetcode Unique Paths II
    leetcode[61] Unique Paths
    leetcode[60] Rotate List
    leetcode Permutation Sequence
    leetcode Spiral Matrix II
  • 原文地址:https://www.cnblogs.com/Friends-A/p/10324452.html
Copyright © 2011-2022 走看看