Dear all, I need the code for counting sort algorithm but I try this code but is not working

#include <iostream>
#include <conio.h>
#include <time.h>
#include <stdlib.h> //srand and rand functions
using namespace std;
void add_random_numbers(long arr[], long b);
void countingSort( long left, long right, long vector[], int k, long length);
long const MADH_MAX_VEKTORIT = 110000;
int main()
{
    long random_vector[MADH_MAX_VEKTORIT];
    long vector[] = { 1000, 10000, 15000, 25000, 30000, 45000, 50000, 60000, 75000, 90000, 100000 };
    long num_elem;
    clock_t tn, tp;
    srand(time(NULL));
    cout << "AlgorithmttNumbers_of_emelmentstttTime(s)n";
    cout << "--------tt-------------------tt-------n";
    for (long i = 0; i < 11; i++)
    {
        num_elem = vector[i];
        add_random_numbers(random_vector, num_elem);
        tn = clock();
        countingSort(random_vector, 0, num_elem);
        tp = clock();
        cout << "countingSort  ttt" << num_elem << "ttt" << (tp - tn) / (double)CLOCKS_PER_SEC << endl;
    }
    getchar();
    return 0;
}
void add_random_numbers(long arr[], long b)
{
    for (long i = 0; i < b; i++)
        arr[i] = rand();
}
void countingSort(long vector[], int k, long length)
{
    int c[] = new int[k];
    for (int i = 0; i < vector.length; i++)
        c[vector[i]]++;
    for (int i = 1; i < k; i++)
        c[i] += c[i - 1];
    int b[] = new int[vector.length];
    for (int i = vector.length - 1; i >= 0; i--)
        b[--c[vector[i]]] = vector[i];
    return b;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.