#include #include #include "wektor.h" using namespace std; bool czy_mniejszy_od_300(int a){ return a < 300; } int main() { Wektor w; for(int i=1;i<=20;i++) w.Dodaj(i); cout << "Poczatkowa kolekcja: " << endl; Wektor::iterator it; for(it=w.begin();it!=w.end();it++) cout << *it << " "; cout << endl; for(it=w.begin();it!=w.end();it++) *it = *it * *it; cout << "Po podniesieniu do kwadratu: " << endl; for(it=w.begin();it!=w.end();it++) cout << *it << " "; cout << endl; cout << "Reverse - odwracanie: " << endl; reverse(w.begin(),w.end()); for(it=w.begin();it!=w.end();it++) cout << *it << " "; cout << endl; cout << "Reverse - odwracanie polowy elementow: " << endl; reverse(w.begin(),w.begin()+w.IleElementow()/2); for(it=w.begin();it!=w.end();it++) cout << *it << " "; cout << endl; cout << "Sort: " << endl; sort(w.begin(),w.end()); for(it=w.begin();it!=w.end();it++) cout << *it << " "; cout << endl; cout << "Random shuffle: " << endl; random_shuffle(w.begin(),w.end()); for(it=w.begin();it!=w.end();it++) cout << *it << " "; cout << endl; cout << "Sort: " << endl; sort(w.begin(),w.end()); for(it=w.begin();it!=w.end();it++) cout << *it << " "; cout << endl; cout << "Fill (wypelnij wartosciami -1, ale tylko pierwsze 10 elementow)" << endl; fill(w.begin(),w.begin()+10,-1); for(it=w.begin();it!=w.end();it++) cout << *it << " "; cout << endl; cout << "Rotate (przesun cyklicznie): " << endl; rotate(w.begin(),w.begin()+w.IleElementow()-1,w.end()); for(it=w.begin();it!=w.end();it++) cout << *it << " "; cout << endl; cout << "Replace (zamien -1 na 144)" << endl; replace(w.begin(),w.end(),-1,144); for(it=w.begin();it!=w.end();it++) cout << *it << " "; cout << endl; cout << "Count (liczba wystapien wartosci 144) = " << count(w.begin(),w.end(),144) << endl; cout << "Count (if x < 300) = " << count_if(w.begin(),w.end(),czy_mniejszy_od_300) << endl; int *m = max_element(w.begin(),w.end()) ; cout << "max_element=" << *m << endl; }