hdu 2072 单词数
2015-03-13 21:57
204 查看
http://acm.hdu.edu.cn/showproblem.php?pid=2072
单词数这道题感觉用c写很麻烦,用c++写就比较简单了。不多说,直接贴代码。
感觉用set更简单,这是网上的代码:
单词数这道题感觉用c写很麻烦,用c++写就比较简单了。不多说,直接贴代码。
#include<iostream> #include<string> #include<vector> #include<sstream> using namespace std; int main() { vector<string> s; string s0,s1; int flag; while(getline(cin,s0)) { if(s0=="#") break; else { s.clear(); istringstream sin(s0); while(sin>>s1) { flag=0; for(int i=0;i<s.size();i++) { if(s[i]==s1) { flag=1; break; } } if(flag==0) s.push_back(s1); } cout<<s.size()<<endl; } } return 0; }
感觉用set更简单,这是网上的代码:
#include <iostream> #include <set> #include <string> #include <sstream>// 不要忘记了 using namespace std; int main() { string art; while(getline(cin,art) && art != "#"){ istringstream stream(art); string word; set<string> map; while(stream >>word){ map.insert(word); } cout <<map.size() <<endl; } return 0; }
相关文章推荐
- HDU 2072 单词数(set)
- hdu-2072-单词数(字典树)
- HDU 2072 单词数
- HDU 2072 单词数 set使用
- hdu 2072 Java 单词数(超级坑) HDU 2072
- HDU 2072 单词数
- HDU 2072 单词数
- HDU 2072 单词数 (map)
- hdu 2072 单词数(set ,stringstream)
- 单词数 HDU - 2072
- hdu 2072 单词数
- HDU 2072 单词数 map
- HDU 2072 单词数
- HDU 2072 单词数(set)
- HDU2072——单词数
- hdu 2072单词数
- HDU 2072 单词数
- acm 杭电(hdu) 2072 单词数【用到了sscanf(首地址,,)】
- HDU2072 单词数
- HDU2072 单词数