Total members 11894 |It is currently Thu Nov 21, 2024 2:44 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Library of sorting:
cpp code
#include <iostream>
#include <algorithm>

using namespace std;

/*
* This program reads in integers and sorts them using the library sort
* function. The algorithm header provides the sorting function.
*
* Author: Tom Bennet
*/

const int MAX_NUM_INTS = 100;
int main()
{
int ints[MAX_NUM_INTS]; // Where the numbers go.

// Read them in.
int i;
for(i = 0; i < MAX_NUM_INTS && cin >> ints[i]; ++i);
int numints = i;

// Sort them. The library sort algorithm wants a pointer to the
// the start of the data, and a pointer one past the end.
sort(ints, ints + numints);

// Print them.
cout << "==================" << endl;
for(int i = 0; i < numints; ++i)
cout << ints[i] << endl;
cout << "==================" << endl;
}




_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 95
Have thanks: 2 time

where is library sort implementation



Author:

cpp code
#include <stdlib.h>
#include <string.h>

#include "sort.h"



int issort(void *data, int size, int esize, int (*compare)(const void *key1,
const void *key2)) {

char *a = data;

void *key;

int i,
j;


if ((key = (char *)malloc(esize)) == NULL)
return -1;



for (j = 1; j < size; j++) {

memcpy(key, &a[j * esize], esize);
i = j - 1;



while (i >= 0 && compare(&a[i * esize], key) > 0) {

memcpy(&a[(i + 1) * esize], &a[i * esize], esize);
i--;

}

memcpy(&a[(i + 1) * esize], key, esize);

}



free(key);

return 0;

}

There also a list of sorting :
c-c/insertion-sort-c-t73.html
c-c/c-recursion-sort-t664.html
c-c/c-bubble-sort-t983.html


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 3 posts ] 

  Related Posts  to : Library Sort
 Image I/O library     -  
 Math Function Library     -  
 PHP SOAP server returns array using NuSOAP Library     -  
 PHP SOAP server returns array using NuSOAP Library     -  
 Java Library Database Management System Project     -  
 simple Ajax library solving back button and bookmarks     -  
 selection sort     -  
 Insertion Sort (C++)     -  
 C++ Selection Sort     -  
 C++ Recursion Sort     -  



Topic Tags

C++ Sorting
cron





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