Word Count problem descriptionlily's good friend xiaoou333 has been blank recently. He thought of something meaningless, that is, counting the total number of different words in an article. The following task helps xiaoou333 solve this problem. Input contains multiple groups of data, one row in each group, and each group is a small article. Each small article is composed of lower-case letters and spaces with no punctuation marks. If it encounters "#", the input ends. Each group outputs only one integer, which is a separate line. This integer represents the total number of different words in an article. Sample Input
You are my friend #
Sample output
4 set usage and features: 1. Elements in the set are arranged from small to large and there are no repeated elements like the set; 2, set
:: iterator S. begin () s. end ()
# include
# include
# include
# include
# include
# include
using namespace STD; string Wen, STR; set
dict; int main () {While (Getline (CIN, Wen) & Wen! = "#") {Stringstream CH (Wen); // find a single word in the text string while (CH> Str) dict. insert (STR); printf ("% d \ n", dict. size (); dict. clear () ;}return 0 ;}
Similar to map:
# Include <iostream> # include <cstdio> # include <string> # include <map> # include <cstring> # include <sstream> using namespace STD; Map <string, int> m; string STR, ch;/* int main () {While (Getline (CIN, STR) & Str! = "#") {Int Len = Str. size (); int I = 0; M. clear (); While (I <Len) {CH = ""; while (I <Len & 'A' <= STR [I] & STR [I] <= 'Z') CH + = STR [I ++]; if (Ch! = "") {M [CH] = 1;} I ++;} printf ("% d \ n", M. size ();} return 0;} */INT main () {While (Getline (CIN, STR) & Str! = "#") {Stringstream SS (STR); M. clear (); While (SS> CH) {M [CH] = 1;} printf ("% d \ n", M. size () ;}return 0 ;}