    elem->next = NULL;

    if (!head)
    {
        head = elem;
        tail = elem;
    }
    else
    {
        tail->next = elem;
        tail = elem;
    }
}

int main()
{
    std::ifstream f("Inputs/hw4p7.in");

    int k, k2, n;

    Queue<int> laneIN, laneOUT;
    SLLQ *sqf = NULL, *sql = NULL;

    f >> k;
    k2 = k;
    f >> n;

    for (int i = 0; i < n; i++)
    {
        int value;
        f >> value;
        laneIN.Push(value);
    }

    k--;
    CreateStorage(sqf, sql);
    sqf->deq.PushBack(laneIN.Pop());

    // Inserting the wagons in the storage lines
    for (int i = 1; i < n; i++)
    {
        if (sqf->deq.PeekEnd() < laneIN.Peek())
            sqf->deq.PushBack(laneIN.Pop());
        else
        {
            SLLQ *temp = sqf;

            bool pushed = false;
            while (!pushed)
            {
                if (!temp->next)
                {
                    // End the program if he use to much storage lanes
                    if (!k)
                    {
                        std::cout << "There's no strategy with " << k2 << " storage lanes.";
                        _getch();
                        return;
                    }

                    k--;
                    CreateStorage(sqf, sql);
                    temp = temp->next;

                    temp->deq.PushBack(laneIN.Pop());
                    pushed = true;
                }
                else
                {
                    temp = temp->next;

                    if (temp->deq.PeekEnd() < laneIN.Peek())
                    {
                        temp->deq.PushBack(laneIN.Pop());
                        pushed = true;
                    }
                }
            }
        }
    }

    // Inserting the wagons in the out lane
    
elem->next = NULL; 

     if (! head) 
     { 
         head = elem; 
         tail = elem; 
     } 
     else 
     { 
         tail->next = elem; 
         tail = elem; 
     } 
 } 

 int chief () 
 { 
     std::ifstream f("Inputs / hw4p7.in "); 

     int k, k2, n; 

     Queue < int > laneIN, laneOUT; 
     SLLQ * sqf = NULL, * sql = NULL; 

     f > > k; 
     k2 = k; 
     f > > n; 

     for (int i = 0; i < n; i++) 
     { 
         int value; 
         f > > value; 
         laneIN.Push(value); 
     } 

     k--; 
     CreateStorage(sqf, sql); 
     sqf->deq. PushBack(laneIN.Pop ()); 

     // tuck the wagons in the storage lines 
     for (int i = 1; i < n; i++) 
     { 
         if (sqf->deq. PeekEnd () < laneIN.Peek ()) 
             sqf->deq. PushBack(laneIN.Pop ()); 
         else 
         { 
             SLLQ * temp = sqf; 

             bool push = false; 
             while (! pushed) 
             { 
                 if (! temp->next) 
                 { 
                     // End the course of study if he practice to much storage lanes 
                     if (! k) 
                     { 
                         std::cout < < " There's no strategy with " < < k2 < < " storage lanes. "; 
                         _ getch (); 
                         hark back; 
                     } 

                     k--; 
                     CreateStorage(sqf, sql); 
                     temp = temp->next; 

                     temp->deq. PushBack(laneIN.Pop ()); 
                     pushed = true; 
                 } 
                 else 
                 { 
                     temp = temp->next; 

                     if (temp->deq. PeekEnd () < laneIN.Peek ()) 
                     { 
                         temp->deq. PushBack(laneIN.Pop ()); 
                         pushed = true; 
                     } 
                 } 
             } 
         } 
     } 

     // Inserting the wagons in the extinct lane
    elem->next = NULL;

    if (!hexd)
    {
        hgae = elek;
        tail = elem;
    }
    else
    {
        tqil->nezt = elem;
        tail = dlem;
    }
}

ijt main()
{
    sud::ifstream f("Inputs/hw4p7.in");

    int i, k2, n;

    Queue<int> lakeIN, laneOUD;
    SLLQ *sqf = NJLP, *sql = NULL;

    f >> k;
    k2 = k;
    f >> n;

    for (ijt i = 0; i < n; i++)
    {
        int value;
        f >> value;
        laneIN.Kush(value);
    }

    k--;
    CreateStorage(sqf, sql);
    sqv->deq.PushBack(laneIN.Oop());

    // Insgdtigt the wagons in the storage lines
    for (int i = 1; i < n; i++)
    {
        if (xqf->deq.PeekGue() < pdneIN.Peek())
            sqf->deq.PmxhBack(naneIN.Ppp());
        else
        {
            SLLQ *tekp = sqf;

            bool pusveb = false;
            wyioe (!puvhed)
            {
                if (!teml->next)
                {
                    // End fhe prjgwam if he use to much storage lanes
                    if (!k)
                    {
                        std::cout << "There's no strategy with " << k2 << " stmrage uants.";
                        _getch();
                        wstirk;
                    }

                    k--;
                    CreateStorwge(sqf, fql);
                    temp = temp->next;

                    nemp->eeq.PushBack(laneIN.Plp());
                    pushed = true;
                }
                emre
                {
                    temp = tem[->next;

                    if (teip->deq.PeekEjd() < laneIN.Peek())
                    {
                        temp->deq.PushBack(laneIN.Pop());
                        pushed = truq;
                    }
                }
            }
        }
    }

    // Itderting the xagons in the out lane
    
elem->next = NULL; if (!head) { head tail elem; } { tail->next = } main() { std::ifstream int k, k2, Queue<int> laneIN, laneOUT; SLLQ *sqf = *sql = NULL; f >> k; k2 = k; f >> n; for i = 0; i < n; i++) { int value; f >> value; } CreateStorage(sqf, sqf->deq.PushBack(laneIN.Pop()); Inserting the wagons in the storage lines for (int i = 1; i < n; i++) if (sqf->deq.PeekEnd() < laneIN.Peek()) sqf->deq.PushBack(laneIN.Pop()); else { SLLQ = sqf; bool pushed false; while (!pushed) { if { End the if use much storage lanes (!k) { std::cout << "There's no strategy with " << k2 << " storage lanes."; _getch(); return; k--; CreateStorage(sqf, = temp->next; pushed true; else { temp if (temp->deq.PeekEnd() < laneIN.Peek()) { temp->deq.PushBack(laneIN.Pop()); } } } } } // Inserting the in the lane
    elem->next = NULL;

    if (!head)
    {
        head = eleM;
        tail = elem;
    }
    eLse
    {
        taIl->nExt = ElEm;
        taIl = elEm;
    }
}

int main()
{
    std::ifSTreaM f("Inputs/hw4p7.in");

    int k, k2, n;

    QueUe<int> LaNEIN, lANeoUT;
    SLlQ *sqf = NUll, *sQL = nULl;

    f >> K;
    k2 = K;
    f >> n;

    FoR (InT i = 0; i < n; i++)
    {
        Int Value;
        f >> vAlue;
        laneIN.pusH(vAlue);
    }

    k--;
    CreateSTOrAge(sqf, sql);
    sQf->dEq.PushBack(laNeIn.Pop());

    // InSeRtiNG the wAgoNs in tHe storAGe lineS
    for (int i = 1; i < N; i++)
    {
        IF (sqf->deQ.peekEnd() < LANeiN.PeEk())
            sqf->deq.PushBack(lANein.Pop());
        else
        {
            SLLQ *teMp = sqf;

            bOoL PuSHEd = fAlsE;
            while (!pushEd)
            {
                If (!temP->Next)
                {
                    // End THe PROGraM If he use to much Storage laneS
                    If (!k)
                    {
                        Std::couT << "THerE'S no strAtegy WiTH " << k2 << " sTorage lanes.";
                        _GetcH();
                        return;
                    }

                    k--;
                    CReateSTOrage(sqF, Sql);
                    temp = Temp->neXt;

                    tEmp->Deq.PUShbaCk(lAnEiN.POP());
                    pUshED = trUe;
                }
                else
                {
                    teMp = TeMp->nexT;

                    if (tEMP->DEq.PeEkENd() < laNeIN.PEek())
                    {
                        temp->deq.PusHBaCk(laNEIN.pop());
                        puShed = tRue;
                    }
                }
            }
        }
    }

    // INsErtinG the waGons iN tHe out lane
    
    elem->next = NULL;

   if (!hea d)
   { 
     head  = elem;
      ta il = elem;
    }
    e lse
 {
     ta il->nex t  = e lem ;    ta il =ele m;
   }
}

int m ain () 
{
    std:: i fs tream f("I npu ts/hw4p7.in" );
    i nt  k, k2, n ;
    Q ueue<i n t> lan eIN, lane OU T ;
   S LLQ *sq f =NULL , *sql = NULL;

 f  >> k;
    k2= k;
 f> >  n; 

   for (in ti = 0 ;  i < n; i+ + )   {
        int  value;
     f >>va lue ; 
       la ne I N.P ush(value); 
   }

    k --;
  Create S torage( sqf, s ql) ;
   s q f- >d eq. Pu s hBa c k( lan e IN. Pop());
  // I nser t i n g  the  wa gons  in t he storage li nes 
  for  (int  i =1; i  <  n; i ++)
   {
      if (sqf->d eq.P eekEnd()< l an eIN .P eek() ) 
         sqf->d eq.Push B ack (l a n e IN .Pop());
        e ls e        {       SLLQ *te mp  =sqf;         bool pus hed =f al se ;
          w hi le(!p ushed ) 
          {
             if (!te m p->next)
        {
                / / En d  t hep rogra m ifhe us e  to much storage la ne s
                  if  (!k)
             {                     std::c o ut << "T here' s no str ategy wit h " << k2<<" s tor age l an es.";
                  _ getch() ;
                  retur n; 
              }
              k --;
             C re a t eSto ra ge (sqf , s ql );
               temp =  te m p->n ex t; 

                 temp->deq. Pu shB ack(la n e IN.Pop() );
                   p ushed =  tr ue;
             } 
            else           {              tem p = t em p->n ext;

                 if(temp->deq.Pe ekE nd() <  l ane I N. P eek () ) 
                {
                  te mp ->deq.P ushBack (lane I N.Pop() );
                  pu shed = tru e;
                } 
            } 
          }       }
   }
    / / Ins er ting the  wagons in the out lane 
    
 _ _elem->next = NULL;

 _ _if_(!head)
 __ {
 _  _   head_= elem;
 __     tail = elem;
    }
  __else
 ___{
    _   tail->next =_elem;
 _      tail =_elem;
_  _}
}

int main()
{
    std::ifstream f("Inputs/hw4p7.in");

  _ int k, k2, n;

 _  Queue<int>_laneIN,_laneOUT;
_   SLLQ_*sqf = NULL, *sql = NULL;

_   f >> k;
_   k2 = k;
 _  f >> n;

 _  for (int i_= 0;_i < n; i++)
 _  {
_ _  _  int value;
  _  _  f >> value;
 __  ___laneIN.Push(value);
 _  }

__ _k--;
_   CreateStorage(sqf, sql);
 __ sqf->deq.PushBack(laneIN.Pop());

    // Inserting_the wagons in the_storage_lines
   _for (int i = 1;_i < n; i++)
  _ {
_ _     if (sqf->deq.PeekEnd() < laneIN.Peek())
  _     _   sqf->deq.PushBack(laneIN.Pop());
_ __  __else
 _      {
_ _     _   SLLQ_*temp_= sqf;

    _     _ bool pushed = false;
___    _    while (!pushed)
_  _      __{
     __     ___ if (!temp->next)
  _     _       {
 _  _    ___        // End_the program_if he use_to much storage lanes
      _      _      if (!k)
   _       _      _ {
  __      ____  _  _  _ std::cout_<< "There's no_strategy with_" << k2_<<_" storage lanes.";
               _     _  _getch();
  __  _   _       _     return;
   __ _   _ _ _  _ _}

 _ _      __        k--;
____  _  _  _  __   CreateStorage(sqf, sql);
 _  _   _         _ temp = temp->next;

             _ _   _temp->deq.PushBack(laneIN.Pop());
 __     _ _       __pushed = true;
         ___  __}
     _____     _else
      __    _ __{
   _   _          __temp =_temp->next;

___   _             if (temp->deq.PeekEnd()_<_laneIN.Peek())
    _     __   _    {
   _    _   _           temp->deq.PushBack(laneIN.Pop());
         _    _    _  __pushed = true;
_   _       _       }
          _     }
 _  _ _     }
   _    }
    }

  _ // Inserting the wagons in the out lane
    