Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- const int SIZE = 10;
- template <class sortAlg>
- sortAlg doSort(sortAlg arr[])
- {
- bool swapped = true;
- int j = 0;
- sortAlg tmp;
- while (swapped)
- {
- swapped = false;
- j++;
- for (int i = 0; i < SIZE - j; i++)
- {
- if (arr[i] > arr[i + 1])
- {
- tmp = arr[i];
- arr[i] = arr[i + 1];
- arr[i + 1] = tmp;
- swapped = true;
- }
- }
- }
- return 0;
- }
- int main()
- {
- double arr[SIZE] = { 5.3, 6.2, 1.7, 4.3, 3.1, 2.8, 8.9, 7.1, 9.0, 0.3 };
- doSort(arr);
- for (int i = 0; i < SIZE; i++)
- {
- cout << arr[i] << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement