Sorts an array of integers - C++ STL Algorithm

C++ examples for STL Algorithm:sort

Description

Sorts an array of integers

Demo Code

#include <iostream>
#include <algorithm>
using namespace std;
// array of numbers
int arr[] = {45, 2, 22, -17, 0, -30, 25, 55};
int main()/*from   www . j  av  a 2  s  .  c  o  m*/
{
   sort(arr, arr+8);           // sort the numbers
   for(int j=0; j<8; j++)      // display sorted array
      cout << arr[j] << ' ';
   cout << endl;
   return 0;
}

Result


Related Tutorials