Answer the question
In order to leave comments, you need to log in
VS is not working correctly, what's the problem?
Visual Studio considers count and compare sort run time to be incorrect, the more numbers in the array to sort, the slower the run time. What could be the problem?
Used code:
//Начало отсчёта времени
auto begin = chrono::steady_clock::now();
// Создание и заполнение нулями массива Count
int* Count = new int[n];
for (int i = 0; i < n; i++)
Count[i] = 0;
// Заполнение массива Count номерами для каждого элемента массива А
for (int i = 0; i < n - 1; i++)
for (int j = i + 1; j < n; j++)
if (a[i] < a[j])
Count[j]++;
else
Count[i]++;
// Создание массива с отсортированными данными
int* R = new int[n];
for (int i = 0; i < n; i++)
R[Count[i]] = a[i];
//Конец отсчета времени
auto end = chrono::steady_clock::now();
auto elapsed_ns = chrono::duration_cast<chrono::nanoseconds>(end - begin);
long double time = elapsed_ns.count() / pow(10, 9);
cout « " Время выполнения : " « setprecision(20) « time « " msec" « endl;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question