This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#pragma once
#ifndef yourpart
#define yourpart
#include <malloc.h>
void swap(int a[], int i, int j)
{
int tmp = a[i];
a[i] = a[j];
a[j] = tmp;
}
/*划分:将基准元素定位在正确位置(基准元素在序列的最左端)。需要时调用swap函数。*/
int Partition(int x[], int n, int &movenum, int &compnum, int &bytesnum)
//请在这里添加你hw1_4的代码。并在你的readme.txt文件中分析Partition()函数的时间复杂度、空间复杂度。
bytesnum = 2 * sizeof(int);
int i = 0;
for (int j = 1; j < n; j++)
compnum++;
if (x[j] < x[0])
swap(x, ++i, j), movenum += 3;
swap(x, 0, i), movenum += 3;
return i;
#endif // !yourpart