Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. template <typename T>
  8. void bubble_sort(vector<T> arr, bool ascending) {
  9.     for (int i = 0; i < arr.size() - 1; i++)
  10.         for (int j = 0; j < arr.size() - i - 1; j++)
  11.             if (arr[j] > arr[j+1])
  12.                 swap(&arr[j], &arr[i]);
  13.  
  14.     if (ascending)
  15.         reverse(arr.begin(), arr.end());
  16. }
  17.  
  18. template <typename T>
  19. class Number {
  20. public:
  21.     T real;
  22.     T imaginary;
  23. private:
  24.     bool operator<(const Number& other) {
  25.         return tie(this->real, this->imaginary) < tie(other.real, other.imaginary);
  26.     }
  27. };
  28.  
  29. int main() {
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement