Advertisement
Guest User

bubbleSortAuf4

a guest
Oct 24th, 2014
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.43 KB | None | 0 0
  1. void Warehouse::bestandsListeAusgeben(){
  2.  
  3.     int lagerplatz;
  4.     int matStock;
  5.  
  6.     sortimentNachBestandSortieren();
  7.  
  8.     cout << "Bestandsliste:" << endl;
  9.     cout.width(10);
  10.     cout << left << "Mat. Nr.";
  11.     cout.width(14);
  12.     cout << left << "Materialtext";
  13.     cout.width(10);
  14.     cout << left << "Bestand";
  15.     cout.width(10);
  16.     cout << left << "Lagerplatz" << endl;
  17.  
  18.     for (int i = 0; i < this->sortiment.size(); i++) {
  19.  
  20.         cout.width(10);
  21.         cout << left << this->sortiment.at(i)->getmatNumber();
  22.         cout.width(14);
  23.         cout << left << this->sortiment.at(i)->getmatText();
  24.         cout.width(10);
  25.         cout << left << this->sortiment.at(i)->getStock();
  26.         cout.width(10);
  27.  
  28.         matStock = this->sortiment.at(i)->getStock();
  29.  
  30.         for (int j = 0; j < matStock ; j++)
  31.         {
  32.            
  33.             lagerplatz = this->sortiment.at(i)->getLocationAtPosition(j);
  34.             lagerPlatzErmitteln(lagerplatz);
  35.             if (j > 0)
  36.             {
  37.             cout.width(34);
  38.             cout << left << "-";
  39.             }
  40.            
  41.         }
  42.         cout << endl;
  43.        
  44.  
  45.     }
  46.  
  47. }
  48.  
  49. void Warehouse::sortimentNachBestandSortieren()
  50. {
  51.     for (int i = 1; i < this->sortiment.size(); i++) // Durchläufe
  52.     for (int j = this->sortiment.size() - 1; j >= i; j--) {// Schritte in einem Durchlauf
  53.         if (this->sortiment.at(j - 1)->getStock() < this->sortiment.at(j)->getStock()) { // vertauschen zweier Elemente falls noetig
  54.             Material* tmp = this->sortiment.at(j - 1);
  55.             this->sortiment.at(j - 1) = this->sortiment.at(j);
  56.             this->sortiment.at(j) = tmp;
  57.         }
  58.     }
  59.  
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement