This commit is contained in:
Mikołaj Rosa 2022-05-09 16:08:57 +02:00
parent 1d5bd756d6
commit 36072aeff8
1 changed files with 16 additions and 1 deletions

View File

@ -12,7 +12,12 @@ void createSortedList(list<int>&, int[], int);
int main() {
demo_lista();
//demo_lista();
list<char> lista{ 'a','l','f','c' };
list<char>::iterator it = ListSearch(lista, 'g');
if (it == lista.end()) cout << "Nie znaleziono";
else cout << *it;
}
void demo_lista() {
@ -52,4 +57,14 @@ void demo_lista() {
for (char a : lista)
cout << a << ' ';
cout << endl;
}
list<char>::iterator ListSearch(list<char>& lista, char znak) {
list<char>::iterator it;
for (it = lista.begin(); it != lista.end(); it++) {
if (*it == znak) return it;
}
return it;
}