UVA 10815 Andy‘s First Dictionary(STL: set)

代码如下:

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <set>
#include <algorithm>
#include <string.h>
using namespace std;
set<string> dict;
int main(){
    string s,b;
    while(cin>>s){
        for(int i=0;i<s.length();i++){
            if(isalpha(s[i])){
                s[i]=tolower(s[i]);
            }
            else{
                s[i]=‘ ‘;
            }
        }
        stringstream ss(s);
        while(ss>>b){
            dict.insert(b);
        }
    }
    for(set<string>::iterator it=dict.begin();it!=dict.end();it++)
    cout<<*it<<endl;
    return 0;
}

原文地址:https://www.cnblogs.com/jianqiao123/p/11218185.html

时间: 2024-08-01 13:45:20

UVA 10815 Andy‘s First Dictionary(STL: set)的相关文章

UVA 10815 Andy&#39;s First Dictionary(字符处理)

Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him, as the number of words that he knows is, well, not quite enough. Instead of thinking up all the words himself, he has a briliant idea. From his book

UVa - 10815 Andy&#39;s First Dictionary(STL)

题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18649 #include <iostream> #include <string> #include <set> #include <sstream> using namespace std; /******************************************************************

UVA - 10815 Andy&#39;s First Dictionary

1 #include <iostream> 2 #include <cstring> 3 #include <algorithm> 4 #include <set> 5 using namespace std; 6 7 set<string> out; 8 9 int main() 10 { 11 string s,temp; 12 while(cin>>s) 13 { 14 int len(s.size()); 15 for(int

UVa10815 Andy&#39;s First Dictionary (STL)

链接:http://acm.hust.edu.cn/vjudge/problem/18649分析:set容器应用.set中每个元素最多只出现一次.自定义类型也可以构造set,必须定义“小于”运算符.set中的元素从小到大已排好序. 1 #include <iostream> 2 #include <string> 3 #include <cctype> 4 #include <set> 5 #include <sstream> 6 using n

【UVA】12504 Updating a Dictionary(STL)

题目 题目 ? ? 分析 第一次用stringstream,真TMD的好用 ? ? 代码 #include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; getchar();//回车 while(n--) { string s1,s2; getline(cin,s1); getline(cin,s2); for(int i=0;i<s1.length();i++) if(!isalpha(s1

【UVA - 10815】Andy&#39;s First Dictionary (set)

Andy's First Dictionary Description 不提英文了 直接上中文大意吧 XY学长刚刚立下了再不过CET就直播xx的flag,为了不真的开启直播模式,XY学长决定好好学习英语.于是他每天都读一篇只包含生词的英语文章,并以自己高达450的智商在一秒钟之内记忆下来. 现在给你一篇XY学长今天要读的文章,请你写一个程序,输出他都学习到了哪些单词.要求:如果文章中有相同的单词,那么仅仅输出一次:而且如果两个单词只有大小写不同,将他们视为相同的单词. Input 测试数据将输入

10815 - Andy&#39;s First Dictionary解答

采用数组链表的方式,来插入读入的单词,逐个字符读入单词. #include <stdio.h> #define LEN 200 #include <string> #include <string.h> #include <stdlib.h> struct node { char word[LEN]; struct node * next; }; typedef struct node Word; int main(){ Word* Dict[30]; fo

UVA 10474:Where is the Marble?(STL初步)

 Where is the Marble?  Raju and Meena love to play with Marbles. They have got a lot of marbles with numbers written on them. At the beginning, Raju would place the marbles one after another in ascending order of the numbers written on them. Then Mee

【UVA】12504 - Updating a Dictionary(map,string,vector模拟)

一般的模拟题,一开始WA,可能是用string的容器放char,改成string就过了 14073581 12504 Updating a Dictionary Accepted C++ 0.032 2014-08-21 07:12:19 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<vector> #include<st