title: Word Count with Sorting C++
body: <p>This is a question I have for my Data Structure class.
  I have completely no idea in dealing with it, can anyone give some hints please?</p>
  
  <ol>
  <li>How to stop the program and ensure the output can be out correctly?</li>
  <li>Whether I have to deal with the mapping?</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/nAkFD.png" rel="nofollow noreferrer">the question paper I had from the professor</a></p>
  
  <p>The following is my coding example:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main()
  {
      string s [100];
  
      for (int i = 0; i &lt; 100; i++) {
          cin &gt;&gt; s[i];
          s[i] = Sort(s[i], s[i+1]);
      }
  
  
      //check the number of time the words repeatcout the answer
      for (int i = 0; i &lt; 100; i++) {
          cout &lt;&lt; s[i] &lt;&lt; count (s[i],s[i+1]) &lt;&lt;endl;
      }
      return 0;
  }
  
  
  string Sort(string current, string next ) {
      if (current &gt; next) {
          string temp = current;
          current = next;
          next = temp;
      }
      else {
          return current;
      }
  }
  
  int count(string word, string Nextword) {
      int count;
      if (word == Nextword) {
          count++;
      }
      else {
          return count;
      }
  }
  </code></pre>