Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include"kopiec.h"
- //sortowanie przez zliaczanie
- void CountingSort(int* input, int size, int m)
- {
- int *chwilowy = new int[m];
- int *output = new int[size];
- for (int i = 0; i < m; i++)
- {
- chwilowy[i] = 0;
- }
- for (int i = 0; i < size; i++)
- {
- chwilowy[(input[i] - 1)] = chwilowy[(input[i] - 1)] + 1;
- }
- for (int i = 1; i < m; i++)
- {
- chwilowy[i] = chwilowy[i] + chwilowy[i - 1];
- }
- for (int i = size - 1; i >= 0; i--)
- {
- output[(chwilowy[(input[i] - 1)] - 1)] = input[i];
- chwilowy[(input[i] - 1)] = chwilowy[(input[i] - 1)] - 1;
- }
- memcpy(input, output, size * sizeof(int));
- }
- void BucketSort(int* A, int size)
- {
- //for (int i = 1; i <= length(A); i++) {
- //}
- }
- int main() {
- int table[10];
- for (int i = 0; i < 10; i++) {
- table[i] = 10 - i;
- std::cout << table[i] << " ";
- }
- std::cout <<std::endl;
- CountingSort(table, 10, 10);
- for (int i = 0; i < 10; i++) {
- std::cout << table[i] << " ";
- }
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement