This commit is contained in:
Mikołaj Rosa 2022-05-09 17:02:51 +02:00
parent 8aa47ad5b8
commit 5a3531337e
1 changed files with 14 additions and 2 deletions

View File

@ -19,10 +19,10 @@ int main() {
if (it == lista.end()) cout << "Nie znaleziono"; if (it == lista.end()) cout << "Nie znaleziono";
else cout << *it;*/ else cout << *it;*/
auto print_char = [](const char& n) { cout << n << ' '; }; /*auto print_char = [](const char& n) { cout << n << ' '; };
for_each(lista.begin(), lista.end(), print_char); cout << endl; for_each(lista.begin(), lista.end(), print_char); cout << endl;
cout << (deleteNode(lista, 2) ? "Usunieto" : "Nie usunieto") << endl; cout << (deleteNode(lista, 2) ? "Usunieto" : "Nie usunieto") << endl;
for_each(lista.begin(), lista.end(), print_char); cout << endl; for_each(lista.begin(), lista.end(), print_char); cout << endl;*/
} }
void demo_lista() { void demo_lista() {
@ -85,3 +85,15 @@ bool deleteNode(list<char>& lista, int numer) {
lista.erase(it); lista.erase(it);
return true; return true;
} }
void createSortedList(list<int>& lista, int tab[], int n) {
for (int i = 0; i < n; i++) {
list<int>::iterator it = lista.begin();
while (lista.end() != it) {
if (*it > tab[i]) {
lista.insert(it, tab[i]);
break;
}
}
}
}