Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include "zad06qs.h"
  2. #include "zad06sw.h"
  3. #include <cstdlib>
  4. #include <iostream>
  5. #include <ctime>
  6. #include <chrono>
  7. using namespace std;
  8.  
  9.  
  10. int main()
  11. {
  12. srand(time(nullptr));
  13. int dlugosc;
  14. cout << "Podaj dlugosc tablicy:";
  15. cin >> dlugosc;
  16.  
  17.  
  18. int* tab1 = new int[dlugosc];
  19. int* tab2 = new int[dlugosc];
  20.  
  21. for (int i = 0; i < dlugosc; i++) {
  22. tab1[i] = rand() %100;
  23. tab2[i] = tab1[i];
  24. }
  25. double t1,t2,t3,t4;
  26.  
  27. t1 = clock();
  28. auto t_start = std::chrono::high_resolution_clock::now();
  29. sw<int>(tab1, dlugosc);
  30. auto t_end = std::chrono::high_resolution_clock::now();
  31.  
  32. t2 = clock();
  33.  
  34. t3 = clock();
  35. Sortowanie<int>(tab2, 0,dlugosc - 1);
  36. t4 = clock();
  37.  
  38.  
  39.  
  40. cout << "Wynik sortowanie przez proste wybieranie : " << (t2-t1)/1000<< "milisekund" << endl ;
  41. cout << "Wynik sortowanie przez proste wybieranie c++ method: " << chrono::duration<double, milli>(t_end-t_start).count()<< "milisekund"<<endl ;
  42. cout << "Wynik sortowanie szybkie : " << (t4 - t3)/1000<< "milisekund" << endl<< endl;
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement