Skip to content

Commit

Permalink
Revert "Fix bug"
Browse files Browse the repository at this point in the history
This reverts commit 2c5404e.
  • Loading branch information
Queequeg92 committed Nov 23, 2014
1 parent 72c0f3d commit cc78ca1
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions ch11/ex11_3_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,15 @@
#include <iostream>
#include <map>
#include <string>
#include <cctype>
#include <algorithm>

void remove_punct(std::string &s)
{
auto iter = s.begin();
while(iter != s.end())
{
if(std::ispunct(*iter))
{
iter = s.erase(iter);
}
else
++ iter;
}
}

//! Exercise 11.4
void word_count_pro(std::map<std::string, int> &m)
{
std::string word;
while(std::cin >> word)
for(std::string word; std::cin >> word; /* */)
{
for(auto& ch : word) ch = std::tolower(ch);
remove_punct(word);
std::remove_if(word.begin(), word.end(), ispunct);
++m[word];

for (const auto &e : m)
Expand All @@ -48,8 +32,7 @@ void word_count_pro(std::map<std::string, int> &m)
void ex11_3()
{
std::map<std::string, std::size_t> word_count;
std::string word;
while(std::cin >> word)
for(std::string word; std::cin >> word; /* */)
{
++word_count[word];
for (const auto &elem : word_count)
Expand Down

0 comments on commit cc78ca1

Please sign in to comment.