1. 程式人生 > >是你飄了,還是我拿不動刀了

是你飄了,還是我拿不動刀了

大小 小寫字母 cin str1 emp find def problems +=

Problem F: 是你飄了,還是我拿不動刀了

Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 673 Solved: 114
Status
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; }

 

是你飄了,還是我拿不動刀了