Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.54 KB | None | 0 0
  1.  
  2.    void Ronda::ficar_benzina(Ronda & re, Ronda & rd, int dist, int & g_disp, Motos & m){
  3.     list<Info>::iterator ite = (re.ron).begin();
  4.     list<Info>::iterator itd = (rd.ron).begin();
  5.     list<Info>::iterator itr = (ron).end();
  6.         int te;
  7.         int td;
  8.         int benz = 0;
  9.     while ((ite != (re.ron).end() or itd != (rd.ron).end())and g_disp >= 0) {
  10.        // falta ananitzar si una llista esta buida al principi!!!
  11.            te = dist*100000 / m.velocidad((*ite).id - 1);
  12.            td = dist*100000 / m.velocidad((*itd).id - 1);
  13.            if (ite == (re.ron).end()) te = 0;
  14.            if (itd == (rd.ron).end()) td = 0;
  15. //FALTA MIRAR SI TE = TD TMB COMAPRAMOS GASOLINA?
  16.            if((te < td or (te == td and (((*ite).g_us < (*itd).g_us) or ((*ite).g_us == (itd).g_us) and (*ite).id < (*itd).id)))  or itd == (rd.ron).end())) and ite != (re.ron).end()) { //afegim el e
  17.               Info aux;
  18.                       benz = int ((m.consumo((*ite).id -1)*dist)/100); //LO QUE Necesitaremos en el recorrido
  19.                       aux.dist = (*ite).dist + dist;
  20.                       aux.g_us = (*ite).g_us + benz; //usada
  21.               aux.id = (*ite).id;
  22.                       aux.t = (*ite).t + te;
  23.                       aux.gas = (*ite).gas;
  24.               if ((m.capacidad_dep((*ite).id -1) - benz) >= 0) {
  25.                         if( g_disp >= benz) {
  26.                                 aux.gas = m.capacidad_dep((*ite).id-1)-benz;
  27.                     g_disp -= benz;
  28.                  (ron).insert(itr,aux);
  29.                     }else {
  30.                      aux.gas = m.capacidad_dep((*ite).id-1) -g_disp;
  31.                         g_disp = 0;
  32.                 }
  33.                  
  34.             }
  35.                      
  36.                     ++ite;
  37.        }else if( itd != (rd.ron).end() or  ite == (re.ron).end() ){ //afegim el d
  38.             Info aux;
  39.                         benz = int ((m.consumo((*itd).id -1)*dist)/100); //LO QUE Necesitaremos en el recorrido
  40.                         aux.dist = (*itd).dist + dist;
  41.                         aux.g_us = (*itd).g_us + benz; //usada
  42.                         aux.t = (*itd).t + td;
  43.             aux.id = (*itd).id;
  44.                         aux.gas = (*itd).gas;
  45.               if ((m.capacidad_dep((*itd).id -1) - benz) >= 0) {
  46.                         if( g_disp >= benz) {
  47.                                 aux.gas = m.capacidad_dep((*itd).id-1) - benz;
  48.                     g_disp -= benz;
  49.                     (ron).insert(itr,aux);
  50.                     }else {
  51.                      aux.gas = m.capacidad_dep((*itd).id-1) - g_disp;
  52.                         g_disp = 0;
  53.                 }
  54.                  //  (ron).insert(itr,aux);
  55.             }
  56.                         ++itd;
  57.       }
  58.     }  
  59.     (ron).sort(ordena_per_temps);                                                  
  60.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement