Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int i, j, array[], userSize;
- char ch;
- //void reverseSort();
- int main()
- {
- cout << "How many integers would you like to sort? \n";
- cin >> userSize;
- int* array = new int[userSize];
- for (i = 0; i < userSize; ++i)
- {
- cout << "Enter digit #" << i + 1 << ": " << endl;
- cin >> array[i];
- }
- for (i = 0; i < userSize; ++i)
- {
- for (j = 0; j < userSize - i - 1; ++j)
- {
- if (array[j] < array[j + 1])
- {
- array[j] = array[j] + array[j + 1];
- array[j + 1] = array[j] - array[j + 1];
- array[j] = array[j] - array[j + 1];
- }
- }
- }
- cout << "Here is that set of values; " << endl;
- for (i = 0; i < userSize; ++i)
- {
- cout << " > " << array[i];
- }
- cout << "\nHere is that set in descending order;\n";
- for (i = 0; i < userSize; ++i)
- {
- cout << " > " << array[i];
- }
- delete[] array;
- cin.get();
- ch = cin.get();
- }
- /*
- void reverseSort()
- {
- userSize = userSizeREV;
- int* array = new int[userSize];
- for (i = 0; i < userSize; ++i)
- {
- for (j = 0; j < userSize - i - 1; ++j)
- {
- if (array[j] < array[j + 1])
- {
- array[j] = array[j] + array[j + 1];
- array[j + 1] = array[j] - array[j + 1];
- array[j] = array[j] - array[j + 1];
- }
- }
- }
- //end
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement