Total members 11890 |It is currently Mon May 20, 2024 11:23 am Login / Join Codemiles

### 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;}`

_________________

 Tweet
Author:
 Posts: 95Have thanks: 2 time

where is library sort implementation

 Tweet
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

 Tweet
Author:
 Posts: 2715Have thanks: 74 time
 Page 1 of 1 [ 3 posts ]

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

C++ Sorting