Facebook
From Morose Matamata, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 275
  1. void wstaw(int x)
  2. {
  3.     if(glowa==NULL)
  4.     {
  5.         glowa = new element;
  6.         glowa->klucz = x;
  7.         glowa->nast = NULL;
  8.         glowa->klucz;
  9.     }
  10.     else
  11.     {
  12.         element *tmp = glowa;
  13.                 element *el = new element;
  14.                 el->klucz = x;
  15.                 bool wstawiona = false;
  16.         while(tmp->nast!=NULL)
  17.         {
  18.             if(tmp->nast->klucz < x)
  19.             {
  20.                                 el->nast = tmp->nast;
  21.                                 tmp->nast = el;
  22.                                 wstawiona = true;
  23.                         }
  24.             tmp=tmp->nast;
  25.         }
  26.         if(wstawiona=false)
  27.                 {
  28.                         tmp->nast = el;
  29.                         el->nast = NULL;
  30.                 }
  31.     }
  32. }