GastonFontenla

Untitled

Oct 26th, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int receta(vector<string> heladera, vector<string> ingredientes, vector<string> &faltantes)
  7. {
  8.     for(int i=0; i<ingredientes.size(); i++)
  9.     {
  10.         bool existe = false;
  11.         for(int j=0; j<heladera.size(); j++)
  12.         {
  13.             if(ingredientes[i] == heladera[j])
  14.             {
  15.                 existe = true;
  16.                 break;
  17.             }
  18.         }
  19.  
  20.         if(existe == false)
  21.         {
  22.             ///Guardar en faltantes
  23.  
  24.             bool yaEsta = false;
  25.             for(int j=0; j<faltantes.size(); j++)
  26.             {
  27.                 if(ingredientes[i] == faltantes[j])
  28.                 {
  29.                     yaEsta = true;
  30.                     break;
  31.                 }
  32.             }
  33.  
  34.             if(yaEsta == false)
  35.             {
  36.                 faltantes.push_back(ingredientes[i]);
  37.             }
  38.         }
  39.     }
  40.    
  41.     return faltantes.size();
  42. }
Advertisement
Add Comment
Please, Sign In to add comment