Search This Blog

Sunday, October 23, 2016

Use of sort function to sort a array in C++

It's a example of doing sort by using sort function in C++. We can use this function to sort
normal any numbers very easily .
#include
using namespace std;
int main()
{
    int arr[] = {1, 5, 8, 9, 6, 7, 3, 4, 2, 0};
    int n = sizeof(arr)/sizeof(arr[0]);
    sort(arr, arr+n);
    cout << "\nArray after sorting using "
         "default sort is : \n";
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    return 0;
}

No comments:

Post a Comment

Check Difference Between Two Database Objects

Step-1. Create Two DBLINK to connect with Two Database then Step-2. define logindb= DBLINKONE define remotedb= DBLINKTWO define schema_name=...