HDU2072

水题,绝对水题,不过作为一个学C的人面对C++的这些东西还是忍不住发一下,这里用到的我不会的以后会发到博客上,由于题比较水,我就先不发题目了

代码如下:(朋友写的,已AC,好像比网上的简单啊)

 1 #include <cstdio>
 2 #include <map>
 3 #include <string>
 4 #include <sstream>
 5 #include <iostream>
 6 using namespace std;
 7 map<string,int>m;
 8 int main()
 9 {
10     string line,word;
11     while(getline(cin,line))
12     {
13         if(line=="#")
14             break;
15         m.clear();
16         int cnt=0;
17         stringstream stream(line);
18         while(stream>>word)
19         {
20             if(m[word]==0)
21                 cnt++;
22             m[word]=1;
23         }
24         cout<<cnt<<endl;
25     }
26 }
原文地址:https://www.cnblogs.com/VectorLin/p/5179343.html