Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. const int TAB_WIELKOSC = 20;
  2.  
  3. main :
  4. int tab[TAB_WIELKOSC] = { 2, 4, 6, 4, 7, 1, 4, 9, 5, 3, 7, 2, 2, 6, 9, 3, 7, 3, 4, 4 };
  5. wyswietl(tab);
  6. countingSort(tab);
  7. wyswietl(tab);
  8.  
  9. void countingSort(int* input) {
  10. int Tab[Podzial] = { 0 };
  11.  
  12. for (int i = 0; i < TAB_WIELKOSC; i++)
  13. {
  14. Tab[input[i]]++;
  15. }
  16. int outputindex = 0;
  17. for (int j = 0; j < Podzial; j++)
  18. {
  19. while (Tab[j]--)
  20. input[outputindex++] = j;
  21. }
  22. }
  23.  
  24. void wyswietl(int *liczby)
  25. {
  26. for (int i = 0; i < TAB_WIELKOSC; i++)
  27. cout << liczby[i] << " ";
  28. cout << endl;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement