Standard C++ Library Class Reference
 if(dist == 2 && *end < *start)
 swap(start, end);
 }
 int main()
 {
 //Initialize a vector using an array of ints
 int arr[10] = {37, 12, 2, -5, 14, 1, 0, -1, 14, 32};
 vector<int> v(arr, arr+10);
 //Print the initial vector
 cout << "The unsorted values are: " << endl << " ";
 vector<int>::iterator i; 
 for(i = v.begin(); i != v.end(); i++)
 cout << *i << ", ";
 cout << endl << endl;
 //Use the new sort algorithm
 quik_sort(v.begin(), v.end());
 //Output the sorted vector
 cout << "The sorted values are: " << endl << " ";
 for(i = v.begin(); i != v.end(); i++)
 cout << *i << ", ";
 cout << endl << endl;
 return 0;
 }
Output :
The unsorted values are:
 37, 12, 2, -5, 14, 1, 0, -1, 14, 32,
The sorted values are:
 -5, -1, 0, 1, 2, 12, 14, 14, 32, 37,
Warning
If your compiler does not support default template parameters, then you need to always supply
the Allocator template argument. For instance, you will need to write :
vector<int, allocator>
instead of :
vector<int>
See Also
Algorithms










