https://docs.google.com/presentation/d/1jsvtWSUbkbT5ZsOIRUQ3zjbcFDzq_7VZ9wRalrny9YQ/edit?usp=sharing
void swap(int &a, int &b)
{
int temp = a;
a = b;
b = temp;
}
void qSort(int *a, int s, int e)//e가 pivot,
{
if (s >= e)return;
int l, t;
for (l = t = s; l < e; l++)
{
if (a[l] < a[e])
{
swap(a[l], a[t]);
t++;
}
}
if (t != e) swap(a[t], a[e]);
qSort(a, s, t - 1);
qSort(a, t + 1, e);
}
댓글 없음:
댓글 쓰기