Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <windows.h>
- #include <iostream>
- #include <thread>
- #include <ctime>
- #include <stdio.h>
- #include <cstdlib>
- #include <string.h>
- using namespace std;
- class GETtime
- {
- public:
- int sec_t;
- int MSCostatok;
- int Stepss;
- int min_t;
- int milisecTotal;//
- void strtT()
- {
- tStart = std::chrono::high_resolution_clock::now();
- chrono::duration<float> strtT = tStart - tStart;
- cout << "strtT: " << strtT.count() << endl;
- }
- void endT()
- {
- tEnd = std::chrono::high_resolution_clock::now();
- chrono::duration<float> duration = (tEnd - tStart) * 1000;
- GETtime::milisecTotal = duration.count();
- GETtime::min_t = (duration.count() / 1000 / 60);
- GETtime::sec_t = int(duration.count() / 1000) % 60;
- GETtime::MSCostatok = int(duration.count()) - min_t * 60 * 1000 - sec_t * 1000;
- chrono::duration<float> strtT = tStart - tStart;
- cout << "Vivid d milisec: " << duration.count() << endl;//
- cout << "minut: " << GETtime::min_t << " sekund: " << GETtime::sec_t << " milisekund " << GETtime::MSCostatok << endl;
- }
- void print_Iteration() {
- cout << " Секунд за 1 итерацию: " << GETtime::milisecTotal / Stepss << endl;
- }
- private:
- std::chrono::time_point<std::chrono::steady_clock> tStart, tEnd;
- };
- int* makeARR(int* arr, int ArrElements) {
- int k = 0;
- while (k < ArrElements) {
- arr[k] = (rand() % 10000) + 1;//
- k = k + 1;
- }
- return arr;
- }
- void sortQuick(int* mas, int fir1, int tail)
- {
- int mid, count;
- int t = fir1, end = tail;
- mid = mas[(t + end) / 2];
- do
- {
- while (mas[t] < mid) t++;
- while (mas[end] > mid) end--;
- if (t <= end)
- {
- count = mas[t];
- mas[t] = mas[end];
- mas[end] = count;
- t++;
- end--;
- }
- } while (t < end);
- if (fir1 < end) sortQuick(mas, fir1, end);
- if (t < tail) sortQuick(mas, t, tail);
- }
- void printMassiv(int* arr3, int n) {
- int i = 0;
- while (i < n) {
- cout << "i" << i << " " << arr3[i] << endl;
- i = i + 1;
- }
- }
- //
- //
- LPWSTR FormatToWIN32(char in[], wchar_t format[128]) {
- mbstowcs(format, in, strlen(in) + 1);
- LPWSTR NewFormat = format;
- return NewFormat;
- }
- int main( int argc, char* argv[])
- {
- GETtime LiveOfFun;
- LiveOfFun.strtT();
- char title[128] = "sortAnzh";
- if (argc != 3) {
- cerr << "Sort - zapustite master\n";
- exit(1);
- }
- cout << "1" << argv[2] << "\n";
- cout << "2" << argv[1] << "\n";
- cout << "3" << argv[0] << "\n";
- sprintf(title + strlen(title), " %s", argv[1]);
- sprintf(title + strlen(title), " %s", argv[2]);
- wchar_t formarW[128];
- LPWSTR pp = FormatToWIN32(title, formarW);
- SetConsoleTitle(pp);
- const int ArrElements = 100;
- int arr[ArrElements];
- int* aRR = makeARR(arr, ArrElements);
- sortQuick(arr, 0, ArrElements - 1);
- printMassiv(arr, ArrElements);
- LiveOfFun.Stepss = ArrElements;
- LiveOfFun.endT();
- LiveOfFun.print_Iteration();
- cout << "sort: выход\n";
- //system("pause");
- Sleep(2000);
- return 0;
- }
- //Запуск программы: CTRL+F5 или меню "Отладка" > "Запуск без отладки"
- // Отладка программы: F5 или меню "Отладка" > "Запустить отладку"
- // Советы по началу работы
- // 1. В окне обозревателя решений можно добавлять файлы и управлять ими.
- // 2. В окне Team Explorer можно подключиться к системе управления версиями.
- // 3. В окне "Выходные данные" можно просматривать выходные данные сборки и другие сообщения.
- // 4. В окне "Список ошибок" можно просматривать ошибки.
- // 5. Последовательно выберите пункты меню "Проект" > "Добавить новый элемент", чтобы создать файлы кода, или "Проект" > "Добавить существующий элемент", чтобы добавить в проект существующие файлы кода.
- // 6. Чтобы снова открыть этот проект позже, выберите пункты меню "Файл" > "Открыть" > "Проект" и выберите SLN-файл.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement