Advertisement
Guest User

dvbmis

a guest
Aug 29th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. {
  11. string inputword;
  12. int numberOfWords = 0;
  13. map <string, int> storage;
  14.  
  15. //Ask user for input.
  16. cout << "Please enter any word you want and enter." << "\n"
  17. << "To end the program, type in 'stop' and push enter."
  18. << "\n" << "You typed following words: " << endl;
  19.  
  20. while (inputword != "stop")
  21. {
  22. cin >> inputword;
  23. cout << endl;
  24.  
  25. if (inputword == "stop")
  26. {
  27. break;
  28. }
  29. storage[inputword] ++;
  30. numberOfWords++;
  31. }
  32.  
  33. for (auto it = storage.begin(); it != storage.end(); ++it)
  34. {
  35. cout << "Your input " << it ->first <<" has been entered: "<< it->second <<" time(s)." <<endl;
  36. cout << "\n";
  37. }
  38. cout << " " << storage.size() << endl;
  39. cout << numberOfWords << endl;
  40. }
  41.  
  42. system("PAUSE");
  43. return EXIT_SUCCESS;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement