Guest User

Untitled

a guest
Apr 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. void Xarxa::ordenar_vector(vector<Tren>& v) {
  2.     int i, j;
  3.     i = 0;
  4.     while (i < v.size()) {
  5.         j = 0;
  6.         while (j < v.size()) {
  7.             if (v[i].consultar_arribada() < v[j].consultar_arribada()) {
  8.                 Tren aux = v[i];
  9.                 v[i] = v[j];
  10.                 v[j] = aux;
  11.             }
  12.             else if (v[i].consultar_arribada() == v[j].consultar_arribada() and v[i].consultar_id() < v[j].consultar_id()) {
  13.                 Tren aux = v[i];
  14.                 v[i] = v[j];
  15.                 v[j] = aux;
  16.             }
  17.             ++j;
  18.         }
  19.         ++i;
  20.     }
  21. }
Add Comment
Please, Sign In to add comment