#include <bits/stdc++.h>
using namespace std;
int n,a[111],b[111],f[111];
int SortQ(int a[222], int b[222], int l, int r)
{
long long mid = a[(l + r) / 2];
int i = l;
int j = r;
int t;
while(i <= j)
{
while(a[i] < mid)
i++;
while(a[j] > mid)
j--;
if(i <= j)
{
t = a[i];
a[i] = a[j];
a[j] = t;
t = b[i];
b[i] = b[j];
b[j] = t;
i++;
j--;
}
}
return i;
}
void quickSort(int a[222], int b[222], int l, int r)
{
int i = SortQ(a, b, l, r);
if(l < i - 1)
quickSort(a, b, l, i-1);
if(i < r)
quickSort(a, b, i, r);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
freopen("HEIGHT.inp","r",stdin);
freopen("HEIGHT.out","w",stdout);
cin >> n;
for (int i=1; i<=n; i++)
{
cin >> a[i];
b[i]=i;
}
quickSort(a,b,1,n);
for (int i=1; i<=n; i++) f[i]=i-1;
quickSort(b,f,1,n);
for (int i=1; i<=n; i++) cout << f[i] << " ";
}
Cho em hỏi code trên em sai bị sai chỗ nào vậy ạ ?