Last active
April 5, 2026 14:32
-
-
Save thinkphp/ed9932ddbb212532a955eb4606a3c58c to your computer and use it in GitHub Desktop.
Exemplu Vector si Map in action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <vector> | |
| #include <map> | |
| using namespace std; | |
| int main() { | |
| map<int, string> studenti; | |
| //adaugare elemente studenti | |
| studenti[1] = "Ana"; | |
| studenti[2] = "George"; | |
| studenti[3] = "Beatrice"; | |
| /* | |
| student<1, "Ana"> | |
| student<2, "George"> | |
| student<3, "Beatrice"> | |
| first, second | |
| */ | |
| //afisare studenti | |
| cout<<"Liste studenti: "; | |
| for(auto& pereche: studenti) { | |
| cout<<pereche.first<<" ---> "<<pereche.second<<endl; | |
| } | |
| vector<int> v = {1,2,3,4,5}; | |
| //iterator | |
| vector<int>::iterator it; | |
| for(it = v.begin(); it != v.end(); ++it) { | |
| cout<<*it<<" "; | |
| } | |
| cout<<"\n STERGERE cu erase"; | |
| vector<int> v2 = {10, 20, 30, 40}; | |
| v2.erase(v2.begin() + 3); | |
| for(int x: v2) { | |
| cout<<x<<" "; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment