Number of words
Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 44427 Accepted Submission (s): 10840
Problem descriptionlily's good friend xiaoou333 recently very empty, he thought of a meaningless thing, is to count the number of different words in an article. Your task below is to help xiaoou333 solve the problem.
Input has multiple sets of data, each set of rows, each of which is a small article. Each small article is composed of lowercase letters and spaces, no punctuation, and when you encounter #, the input ends.
Output each group only outputs an integer, which represents the total number of different words in an article.
Sample Inputyou is my friend#
Sample Output4
#include <iostream>#include<sstream>#include<Set>#include<string>using namespacestd;intMain () {strings; while(Getline (cin,s) &&s!="#") {Istringstream cin (s); Set<string>words; stringW; while(cin>>W) Words.insert (W); cout<<words.size () <<Endl; }}
Application of STL in application of Istringstream