Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void qSort(int vector[],int st,int dr)
- {
- int temp,min,max,mijl;
- mijl = vector[st+(dr-st)/2]; //luam mijlocul intervalului
- min = st; max = dr;
- do
- {
- while(vector[min] < mijl) min++; //crescator
- while(vector[max] > mijl) max--; //crescator
- if(min <= max) //interschimbare
- {
- temp = vector[min];
- vector[min++] = vector[max];
- vector[max--] = temp;
- }
- }while(min <= max); //la fiecare pas sortam "mai bine" intervalul st-dr
- //cand numai avem ce face schimbam intervalul
- if(st < max) qSort(vector,st,max); //crescator
- if(dr > min) qSort(vector,min,dr); //crescator
- }
Add Comment
Please, Sign In to add comment