Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "headlines.h"
- Stats InsertionSorter::SortArray(long * arrayToSort, unsigned length)
- {//Сортировка вставками
- Stats insertReport("Вставки");
- this->SetTempArray(arrayToSort, length);
- for (unsigned i = 0; i < length; i++)
- {
- insertReport.compareCount++;
- for(int j = i; j > 0 && this->tempArray[j] < this->tempArray[j - 1]; j--)
- {
- insertReport.swapCount++;
- swap(this->tempArray[j], this->tempArray[j - 1]);
- }
- }
- ShowArray(tempArray, length);
- return insertReport;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement