Total members 11891 |It is currently Wed Jun 26, 2024 3:21 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Using the sorting function inside the C++ "algorithm", "functional" and "iterator".
cpp code
/* The following code example is taken from the book
* "The C++ Standard Library - A Tutorial and Reference"
* by Nicolai M. Josuttis, Addison-Wesley, 1999
*
* (C) Copyright Nicolai M. Josuttis 1999.
* Permission to copy, use, modify, sell and distribute this software
* is granted provided this copyright notice appears in all copies.
* This software is provided "as is" without express or implied
* warranty, and with no claim as to its suitability for any purpose.
*/
#include <iostream>
#include <algorithm>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
int coll[] = { 5, 6, 2, 4, 1, 3 };

// sort beginning with the second element
sort (coll, coll+6);

// print all elements
copy (coll, coll+6,
ostream_iterator<int>(cout," "));
cout << endl;
}

/*
1 2 3 4 5 6

*/




_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 95
Have thanks: 2 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Array sort
 Sort associative array     -  
 balloon sort algorithm C++ implementation code-sorting array     -  
 Bubble Sort Algorithm Java Implementation Code-Sorting Array     -  
 Sort strings java-Sorting Array of Strings     -  
 Array difference for associate array     -  
 C++ Selection Sort     -  
 Insertion Sort (C++)     -  
 Library Sort     -  
 C++ Recursion Sort     -  
 String Sort     -  



Topic Tags

C++ Sorting, C++ Arrays






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com