是你飘了,还是我拿不动刀了

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;
}

 

 

转载于:https://www.cnblogs.com/jj81/p/8098570.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值