Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Sort(int li, int ls, int v[])
- {
- int min, max, m, temp;
- min = li;
- max = ls;
- m = v[(li + ls) / 2];
- cout << "THIS IS THE " << i2 << " PASS THROUGH THIS FUNCTION" << endl << endl;
- i2++;
- cout << "Min is:" << min << endl;
- cout << "Max is:" << max << endl;
- cout << "M is:" << m << endl;
- while (min <= max)
- {
- cout << "Min is <= max and is:" << min << endl;
- cout << "Max is >= min and is:" << max << endl;
- while (v[min] > m) {
- min++;
- cout << "New min is:" << min << " " << "because v[min]=" << v[min-1] << " is > m: " << m << endl;
- };
- while (v[max] < m)
- {
- max--;
- cout << "New max is:" << max << " " << "because v[max]=" << v[max+1] << " is < m=" << m << endl;
- };
- if (min <= max)
- {
- cout << "This is happening because min=" << min << " is <= than max=" << max << endl;
- temp = v[min];
- cout << "This is v[min] before it's changed: " << v[min] << " and this is v[max] before: " << v[max] << endl;
- v[min++] = v[max];
- v[max--] = temp;
- cout << "This is v[min] after it's changed: " << v[min] << " this is v[max] after change: " << v[max] << endl;
- cout << "This is max: " << max << " and this is min: " << min << endl;
- };
- };
- cout << "The new array is: " << endl;
- for (i = 1; i <= k; i++)
- cout << v[i] << " ";
- cout << endl;
- cout << "This is li: " << li << " and this is ls: " << ls << endl;
- if (li < max)
- {
- cout << "This is happening because li < max therefor: " << li << " < " << max << endl << endl;
- Sort(li, max, v);
- };
- if (ls > min)
- {
- cout << "This is happening because ls > min therefor: " << ls << " > " << min << endl << endl;
- Sort(min, ls, v);
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement