#include
#include
#include
using namespace std;
struct element{
element *next;
};
bool czyPusty(element *stos){
bool wynik = stos == nullptr ? true : false;
return wynik;
}
void dodajElement(element*& stos){
srand(time(nullptr));
element* el = new element;
el->liczba = rand()%100 +0;
el->next = stos;
stos = el;
}
void usunElement(element*& stos){
if(stos != nullptr){
element* temp = stos;
stos = stos->next;
delete temp;
}
}
int
if(stos != nullptr){
return stos->liczba;
}else{
return -1;
}
}
void usunWszystkieElementy(element*& stos){
while(!czyPusty(stos)){
usunElement(stos);
}
}
int
{
cout << "Menu:" << "n"
<< "1 - sprawdzenie czy stos jest pusty" << "n"
<< "2 - dodanie elementu na stos" << "n"
<< "3 - usuniecie elementu ze stosu" << "n"
<< "4 - pobranie elementu ze stosu" << "n"
<< "5 - usunięcie wszystkich elementów ze stosu" << "n"
<< "6 - wyjście z programu" << "n"
<< endl;
element* stosZNullPnt = nullptr;
int
int i = (begin - 1);
for (int j = begin; j < end; j++) {
if (tab[j].suma_gotowki <= pivot)
while(menu != 6){
cin >> menu;
switch (menu){
case 1:
{
swap(tab[i], tab[j]);
string komunikat = czyPusty(stosZNullPnt) ? "Pusty" : "Niepusty";
cout << komunikat << endl;
}
break;
case 2:
dodajElement(stosZNullPnt);
break;
case 3:
usunElement(stosZNullPnt);
break;
case 4:
{
int ostatni = pobierzElement(stosZNullPnt);
cout << "Ostatni element to: " << ostatni << endl;
break;
}
case 5:
usunWszystkieElementy(stosZNullPnt);
break;
case 6:
return 0;
}
}
}
void quickSort(bank *tab, int begin, int end) {
if (begin < end) {
int partitionIndex = partition(tab, begin, end);
quickSort(tab, begin, partitionIndex - 1);
quickSort(tab, partitionIndex + 1, end);
}
}