C++ Array sort via sort() function

Description

C++ Array sort via sort() function

#include <iostream>
#include <algorithm>
using namespace std;
// array of numbers
int arr[] = {45, 2, 22, -17, 0, -30, 25, 55};
int main()// w  w  w .j  a  v  a  2  s .co  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;
}



PreviousNext

Related