zoukankan      html  css  js  c++  java
  • 是你飘了,还是我拿不动刀了

    Problem F: 是你飘了,还是我拿不动刀了

    Time Limit: 1 Sec  Memory Limit: 128 MB
    Submit: 673  Solved: 114
    Description

    Eternally给出长度在1000以内的英语文章,让你找出文章中的单词,按照英语的格式是每个单词是以空格分开的,但是呢,在这里不同,每个单词是以除大小写字母以外的字符来分开的。

    例如Eternally#is#a#student中Eternally,is,a,student是单词。

    (不必多想,Eternally输入的文章中的每个单词有可能在英语中不是单词)。

    Input

    输入包含多组输入,每行是一篇文章(文章,是没有空格的)。

    Output

    输出有特定的格式,输出单词时请按照单词在文章中的顺序输出单词。(如果同一个单词有多个,那么就只输出最先出现的那个),如果是Eternally开玩笑给的文章中没单词,那么输出NO.

    Sample Input
    Eternally@is@a@student
    Sample Output
    Case 1:
    Eternally
    is
    a
    student

    #include<bits/stdc++.h>
    using namespace std;
    map<string,int>mapp;
    map<int ,string>mapp2;
    int main()
    {
        char str[1005];
        string str1;
        int len;
        int id,id2;
        id = 0;
        id2 = 0;
        while(cin>>str){
            id++;
            mapp.clear();
            mapp2.clear();
            len = strlen(str);
            str1="";
            for(int i = 0 ;i <= len; i++)
            {
                if(str[i] >= 'A'&& str[i] <= 'Z' || str[i] >= 'a' && str[i] <= 'z') {
                    str1 += str[i];
                } else if(str1.length()!= 0){
                    if(mapp.find(str1)==mapp.end())
                        mapp[str1] = id2++;
                    str1 = "";
                }
            }
            cout<<"Case "<<id<<":"<<endl;
            if(mapp.empty()) cout<<"NO"<<endl;
            else{
                map<string,int>::iterator it;
                map<int,string>::iterator it2;
                for(it = mapp.begin(); it != mapp.end(); it++) {
                    mapp2[it->second] = it->first;
                }
                for(it2 = mapp2.begin(); it2 != mapp2.end();it2++)
                    cout<< it2->second <<endl;
            }
            
        }
        
        return 0;
    }
     
  • 相关阅读:
    button 样式 GIS
    将一个json格式的字符串转换为一个实体对象
    统一将数据库中的数据类型转换为另外一种
    Redis学习16两种主从复制的模式
    阿里云服务器reboot后,用Xshell连接不上的解决办法
    Redis学习主从复制,搭建集群
    Redis学习15 发布订阅
    ASP.NET Eval多参数绑定
    面试时如何说辞职理由(转)
    (转)简单的js弹出窗口效果
  • 原文地址:https://www.cnblogs.com/jj81/p/8098570.html
Copyright © 2011-2022 走看看