Why don't try this code?
Code:
void QuickSort(int start, int end, int arr[])
{
     if (start >= end)
        return;
        
    int p = (start + end) / 2;
    
    int i = start;
     int  j = end;
    
    while (i<j)
    {
          while(arr[i]<arr[p] && i<p)
             i++;
          while(arr[j]>arr[p] && j>p)
             j--;
          
        int  temp = arr[i];
          arr[i] = arr[j];
          arr[j] = temp;
          if (p == j )
          {
             p = i;
             j--;
          }
          else
              if (p==i)
              {
                 p = j;
                 i++;
              }
              else
              {
                  i++;
                  j--;
              }
    }
    
    QuickSort(start, p-1, arr);
    QuickSort(p+1, end, arr);
}

Last edited by shabbir; 22Jul2008 at 21:56.. Reason: Code block