O_Egor

33(1 балл) (sort s pred)!!!

Jan 9th, 2020
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include <vector>
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <cmath>
  5. #include <string>
  6. #include <set>
  7. #include <map>
  8. #include <iomanip>
  9. #include <time.h>
  10. #include <stdlib.h>
  11. using namespace std;
  12.  
  13. #define re return
  14. #define pb push_back
  15. #define eb emplace_back
  16. #define all(x) (x).begin(), (x).end()
  17. #define fi first
  18. #define se second
  19. #define sqrt(x) sqrt(abs(x))
  20. #define pi (3.14159265358979323846264338327950288419716939937510)
  21. #define unique(v) v.resize(unique(all(v)) - v.begin())
  22. #define bipbup ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
  23.  
  24. typedef vector<int> vi;
  25. typedef vector<vi> vvi;
  26. typedef pair<int, int> ii;
  27. typedef vector<ii> vii;
  28. typedef vector<string> vs;
  29. typedef double D;
  30. typedef long double ld;
  31. typedef long long ll;
  32. typedef pair<ll, ll> pll;
  33. typedef vector<ll> vll;
  34. typedef unsigned long long ull;
  35.  
  36. bool myPred(int x, int y)
  37. {
  38.     x = abs(x) % 10;
  39.     y = abs(y) % 10;
  40.     return x < y;
  41. }
  42.  
  43. int main()
  44. {
  45.     vi v;
  46.  
  47.     int num;
  48.     while (cin >> num)
  49.         v.push_back(num);
  50.  
  51.     sort(all(v), myPred);
  52.  
  53.     for (int i = 0; i < v.size(); i++)
  54.         cout << v[i] << ' ';
  55. }
  56. /// 19 11 24 38 33 77 22 33 95 24 76 88 - 19 11 24 38 33 77 22 33 95 24 76 88
Add Comment
Please, Sign In to add comment