map 数单词

  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4. #include <string.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. using namespace std;
  8. int main()
  9. {
  10. char c;
  11. map<string,int> word;
  12. while((c=getchar() )!='#')
  13. {
  14. string temp="";
  15. while(c!=' '&&c!=' '&&c!='#')
  16. {
  17. temp+=c;
  18. c=getchar();
  19. }
  20. //int m=word.size();
  21. if(c=='#') return 0;
  22. if(temp.length() ) word.insert(map<string,int> :: value_type(temp,0)) ;
  23. if(c==' ')
  24. {cout<<word.size()<<endl; word.clear();}
  25. }
  26. return 0;
  27. }





附件列表

    原文地址:https://www.cnblogs.com/sober-reflection/p/96175a1bdcc7ff926bbcfc839eb605c4.html