Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: C++  |  size: 0.56 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //Rikiuoja sarasa burbuliuko metodu, reikia <= operatoriaus
  2. template <typename TDUOM,typename TPRAKTAS>
  3. void Sarasas<TDUOM,TPRAKTAS>::Rikiuoti()
  4. {
  5.         if (n < 2) //ar yra ka rykiuot
  6.                 return;
  7.         bool bk = true;
  8.         while (bk)
  9.         {
  10.                 bk = false;
  11.                 Mazgas<TDUOM> *s1 = s;
  12.                 Mazgas<TDUOM> *s2 = s->GautiSek();
  13.                 for (int x=1; x<n ;x++, s1=s2, s2=s2->GautiSek())
  14.                         if (*s2->GautiDuom() <= *s1->GautiDuom())
  15.                         {
  16.                                 TDUOM *elem = s1->GautiDuom();
  17.                                 s1->KeistiDuomAdr(s2->GautiDuom());
  18.                                 s2->KeistiDuomAdr(elem);
  19.                                 bk = true;
  20.                         }
  21.         }
  22. }