Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <ctime>
- #include <iomanip>
- #include <windows.h>
- class PomiarCzasu
- {
- double solutionTime;
- DWORD czasA, czasB;
- public:
- PomiarCzasu()
- {
- solutionTime = 0.0;
- czasA = 0;
- czasB = 0;
- }
- void Start()
- {
- czasA = GetTickCount();
- }
- void Stop()
- {
- czasB = GetTickCount();
- }
- void PodajCzasPocz()
- {
- std::cout << "Czas poczatkowy to: " << czasA << std::endl;
- }
- void PodajCzasKon()
- {
- std::cout << "Czas koncowy to: " << czasB << std::endl;
- }
- double IleCzasu()
- {
- solutionTime = (czasB - czasA)/1000;
- return solutionTime;
- }
- };
- void heap_sort(int d[], int n)
- {
- for (int i = 2; i <= n - 1; i++) {
- int j = i;
- int k = j / 2;
- int x = d[i];
- while ((k > 0) && (d[k] < x)) {
- d[j] = d[k];
- j = k;
- k = j / 2;
- }
- d[j] = x;
- }
- }
- void zadanie2()
- {
- int tab[100];
- for (int &i : tab) i = rand() % 100;
- PomiarCzasu czas;
- czas.Start();
- heap_sort(tab,100);
- czas.Stop();
- std::cout << czas.IleCzasu() << std::endl;
- }
- int main() {
- srand(time(NULL));
- zadanie2();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement