set的应用
1 #include<iostream> 2 #include<cstdio> 3 #include<string> 4 #include<set> 5 using namespace std; 6 int main() 7 { 8 freopen("input.txt","r",stdin); 9 string s,s1; 10 11 bool flag; 12 while(getline(cin,s) && s != "#") 13 { 14 set<string>goal; 15 flag = 0; 16 s += " "; 17 for(int i = 0; i < s.size(); i++) 18 { 19 if(s[i] != ‘ ‘) 20 { 21 s1 += s[i]; 22 flag = 1; 23 } 24 else if(flag) 25 { 26 goal.insert(s1); 27 s1.clear(); 28 flag = 0; 29 } 30 } 31 cout<<goal.size()<<endl; 32 } 33 }
原文地址:http://www.cnblogs.com/imLPT/p/3861928.html