Advertisement
Kimossab

CamSemMOt

Jun 28th, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. //Fun鈬o que devolve o n伹ero de camis sem motorista
  2. int NumCamSemMot(ptGES gestor)
  3. {
  4.     if (!gestor || !gestor->Camioes || !gestor->Motoristas)
  5.         return 0;
  6.  
  7.     gestor->Historico = fopen("Historico.csv", "a");
  8.     fprintf(gestor->Historico, "%s;%s\n", __FUNCTION__, __DATE__);
  9.     fclose(gestor->Historico);
  10.  
  11.     NOCAM * C = gestor->Camioes->prim;
  12.     NOAFE *A;
  13.     int count = 0;
  14.     int auxid;
  15.  
  16.     while (C)
  17.     {
  18.         auxid=-1;
  19.         A = gestor->Afetacao->ult;
  20.         while (A)
  21.         {
  22.             if(auxid == -1)
  23.             {
  24.                 if (C->info->id == A->info->id_cam)
  25.                 {
  26.                     auxid = A->info->id;
  27.                     A=A->seg;
  28.                     continue;
  29.                 }
  30.                 A = A->ant;
  31.             }
  32.             else
  33.             {
  34.                 if(auxid == A->info->id)
  35.                     break;
  36.                 A=A->seg;
  37.             }
  38.         }
  39.         if(!A) //Se o aux id for -1 quer dizer que nao encontrou o camiao.
  40.             count++;
  41.         C = C->seg;
  42.     }
  43.  
  44.     return count;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement