Advertisement
silentkiler029

ispc2-F

Aug 15th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. /*    BISMILLAHIR-RAHMANIR-RAHIM
  2.  ____________________________________
  3. |                                    |
  4. |       SHANTO_SUST_SWE-19_029       |
  5. |____________________________________|
  6. */
  7.  
  8. #include <bits/stdc++.h>
  9.  
  10. using namespace std;
  11.  
  12. #define ll          long long
  13. #define fastio      ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
  14. #define pb          push_back
  15. #define Pi          acos(-1.0)
  16. #define r0          return 0
  17. #define endl        "\n"
  18. #define show(x)     cout << x << endl
  19. #define take(x)     cin >> x
  20. #define debug       1
  21.  
  22. struct fraction{
  23.     long double x, y;
  24.     long double d;
  25. };
  26.  
  27. int main()
  28. {
  29.     int n, i, j;
  30.     cin >> n;
  31.     vector < fraction > f(n);
  32.     fraction temp;
  33.  
  34.     for(i = 0; i < n; i++) {
  35.         cin >> f[i].x >> f[i].y;
  36.         f[i].d = f[i].x / f[i].y;
  37.     }
  38.  
  39.     for(i = 0; i < n; i++) {
  40.         for(j = i + 1; j < n; j++) {
  41.             if(f[i].d < f[j].d) {
  42.                 temp = f[j];
  43.                 f.erase(f.begin() + j);
  44.                 f.insert(f.begin() + i, temp);
  45.             }
  46.         }
  47.     }
  48.  
  49.     for(i = 0; i < n; i++) {
  50.         cout << (long long)f[i].x << " " << (long long)f[i].y << endl;
  51.     }
  52.  
  53.     r0;
  54. }
  55.  
  56. //ALHAMDULILLAH
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement