Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <thread>
- #include <mutex>
- #include <string.h>
- #include <ctime>
- #include "sort.cc"
- using namespace std;
- void new_array(int *&mas, int &length, const int el)
- {
- int *newArray = new int[length + 1];
- for (int l = 0; l < length; l++)
- {
- newArray[l] = mas[l];
- }
- newArray[length] = el;
- mas = newArray;
- }
- int main() {
- int* mas = new int[2];
- mas[0] = 9;
- mas[1] = 8;
- cout << "Work time posl" << " " << "Work time par" << " " << "Size" <<endl;
- for (int i = 2; i < 100; i++)
- {
- std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
- merge_sort_par(mas, i);
- std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
- cout << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
- cout.width(23);
- std::chrono::steady_clock::time_point startp = std::chrono::steady_clock::now();
- merge_sort_pos(mas, i);
- std::chrono::steady_clock::time_point endp = std::chrono::steady_clock::now();
- cout << std::chrono::duration_cast<std::chrono::microseconds>(endp - startp).count();
- cout.width(23);
- cout << i << endl;
- new_array(mas,i,i);
- for (int iter = 0; iter < i - 1; iter++)
- {
- if (mas[iter] > mas[iter + 1])
- {
- cout << "The sort isn't correct" << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement