Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. std::cout << "Hello, World!" << std::endl;
  10. int n = 10000000;
  11. int c[] = {510774, 227011, 100894, 44842, 19930, 8858, 3937, 1750, 701, 301, 132, 57, 23, 10, 4, 1};
  12. string *v;
  13. v = new string[n];
  14. for (int i = 0; i < n; i++) {
  15. v[i] = rand() % 57 + 65;
  16. }
  17. string temp;
  18. int gap;
  19. clock_t t = clock();
  20. clock_t clock1,clock2;
  21. clock1 = clock();
  22. int k = 0;
  23. for( int x = 0; x < 16; ++x ){
  24. gap = c[x];
  25. //for (gap = 2 * (n / 4 ) + 1; gap > 0; gap /= 2 + 1) {
  26. for(int i = gap; i < n; i++) {
  27. for(int j = i - gap; j >= 0 && v[j] > v[j + gap]; j-=gap) {
  28. temp = v[j];
  29. v[j] = v[j + gap];
  30. v[j + gap] = temp;
  31. }
  32. }
  33. }
  34.  
  35. clock2 = clock();
  36. std::cout<< "Shell time "<< (float)(clock2 - clock1)/ CLOCKS_PER_SEC << " "<< std::endl;;
  37.  
  38.  
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement