title: how to set the pivot in quick sort
body: <p>I just update my codes it works but there some problems when I run it. I put some "cout" to debug my partiton part and I don't know whay it always set 0 to pivot.(the pivot should be last number that I inputed)
  <img src="https://i.stack.imgur.com/tQ9cw.png" alt="enter image description here"></p>
  
  <p>Here is my code</p>
  
  <pre><code>    int partiton(vector&lt;int&gt; &amp;a, int low, int up)
  {
        int pivot = a[up];
        int i = low-1;
        for (int j = low; j &lt; up; j++)
        {
              if(a[j] &lt;= pivot)
              {
                    i++;
                    swap(a[i], a[j]);
              }
        }
        swap(a[i+1], a[up]);
        cout&lt;&lt;"pivot: ";
        cout&lt;&lt;pivot&lt;&lt;" "&lt;&lt;endl;
        return i+1;
  }
  
  void quickSort(vector&lt;int&gt; &amp;a, int low, int up)
  {
        if(low &lt; up)
        {
              int mid = partiton(a, low, up);
              //watch out! The mid position is on the palce, so we don't need to consider it again
              //That's why below is mid-1, not mid! Otherwise it will occur overflow error!
              quickSort(a, low, mid-1);
              quickSort(a, mid+1, up);
        }
  }
  
  void quickSort(vector&lt;int&gt;&amp;, int, int);
  
  int main()
  {
      vector&lt;int&gt; A;
  
      int numbers;
  
      while(cin&gt;&gt;numbers)
      {
          A.push_back(numbers);
      }
  
      int low = 0;
      int up = A.size();
  
      cout&lt;&lt;"No sorted numbers: ";
  
      for(int i; i &lt; up; i++)
      {
          cout&lt;&lt;A[i]&lt;&lt;" ";
      }
      cout &lt;&lt; endl;
  
      quickSort(A, low, up);
  
      cout&lt;&lt;"Has sorted numbers: ";
  
      for(int i; i &lt; up; i++)
      {
          cout&lt;&lt;A[i]&lt;&lt;" ";
      }
      cout&lt;&lt;endl;
  }
  </code></pre>