1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

#include <iostream>
using namespace std;
int dividing(int * T, int N, int l, int p)
{
int Rn = 0;
int Ln = 0;
int * R = new int[N1];
int * L = new int[N1];
//if(N==1) return;
for(int i=l; i<p; i++)
{
if(T[0]>T[i])
{
L[Ln] = T[i];
Ln++;
}
else
{
R[Rn] = T[i];
Rn++;
}
}
T[Ln+1]=T[0];
for(int i=0;i<Ln;i++)
{
T[i]=Ln[i];
}
for(int i=(pRn)+1;i<N;i++)
{
T[i]=Rn[i];
}
return pRn;
delete R;
delete L;
}
void sort(int * T, int N, int l, int p)
{
int q;
if(q>=1)
{
q = dividing(T, N, l, p);
sort(T, N, l, q);
sort(T, N, q+1, N);
}
}
int main()
{
int T[7] = {3,5,2,1,6,7,8};
sort(T,7,0,7);
for(int i=0;i<7;i++)
cout << "[" << T[i] << "] ";
}
