Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- #include <string>
- #include <iterator>
- #include <algorithm>
- #include <map>
- #include <fstream>
- using namespace std;
- bool verif (string s)
- {
- return s[0]=='M';
- }
- int main()
- {list <string> nume;
- nume.push_back ("Ion");
- nume.push_front ("Maria");
- nume.push_back ("Andrei");
- nume.push_front ("Marius");
- nume.push_back ("Ioana");
- nume.push_back ("Ioana");
- nume.push_back ("Ioana");
- for (list <string>::const_iterator it=nume.begin(); it!=nume.end();it++)
- cout<<*it<<endl;
- //iteratori de scriere + algoritm
- ostream_iterator <string> oi (cout,"-");
- copy (nume.begin (), nume.end (), oi);
- cout<<endl;
- nume.sort (greater <string>());
- copy (nume.begin (), nume.end (), oi);
- cout<<endl;
- int a=count (nume.begin(), nume.end (),"Ion");
- cout<<a;
- cout<<endl;
- map <string, int> m;
- for (list<string>::const_iterator it=nume.begin (); it!=nume.end ();it++)
- m[*it]++;
- for (map <string, int>::const_iterator it=m.begin();it!=m.end();it++)
- cout<<it->first<<" "<<it->second<<" ";
- cout<<endl;
- int mycount = count_if (nume.begin(), nume.end(), verif);
- cout<<mycount;
- cout<<endl;
- string f = "main.cpp";
- ifstream fsiIn (f.c_str());
- ifstream fsi;
- istream_iterator <string> in (fsiIn), end;
- vector <string> v (in, end);
- copy (in, end, v.begin());
- for (vector <string>::const_iterator it=v.begin(); it!=v.end();it++)
- cout<<*it<<endl;
- sort (v.begin(), v.end ());
- ostream_iterator <string> o (cout, "\n");
- unique_copy (v.begin(), v.end(), o);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement