#include #include using namespace std; int main(void){ list ahel; ahel.push_back(5); ahel.push_back(7); ahel.push_back(3); ahel.push_back(8); list::iterator i; for(i=ahel.begin(); i != ahel.end(); ++i){cout << *i << " ";} cout << endl; i=ahel.begin(); i++; i++; ahel.erase(i); //eemaldab 3nda elemendi for(i=ahel.begin(); i != ahel.end(); ++i){cout << *i << " ";} cout << endl; int eemaldatav=7; i=ahel.begin(); while(i!=ahel.end() && *i!=eemaldatav){i++;} //otsib sobiva väärtuse, väärtuse puudumisel jõuab lõppu if(i!=ahel.end()){ahel.erase(i);} for(i=ahel.begin(); i != ahel.end(); ++i){cout << *i << " ";} cout << endl; //tagurpidi väljatrükk list::reverse_iterator t; for(t=ahel.rbegin(); t!=ahel.rend(); ++t){cout << *t << " ";} cout << endl; ahel.clear(); //Kustutatakse kõik cout << "Elementide arv: " << ahel.size() << endl; return 0; } /* [jaagup@minitorn c]$ ./a.out 5 7 3 8 5 7 8 5 8 8 5 Elementide arv: 0 */