Skip to content

Commit

Permalink
Update according to S04 term
Browse files Browse the repository at this point in the history
  • Loading branch information
ramtung committed Feb 8, 2025
1 parent d389f32 commit c98abb1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 41 deletions.
65 changes: 27 additions & 38 deletions 02_Containers_Iterators/02_VectorDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,33 @@
#include <iostream>
using namespace std;

int main()
{
vector<double> vec;
// vec[0] = 10;
vec.push_back(1.3);
vec[0] = 12.4;
int main() {
vector<double> u;
u.push_back(1.3);
u.push_back(4.5);
cout << u[0];

vector<int> v(6);
v[0] = 5;
v[1] = 7;
v[2] = 9;
v[3] = 4;
v[4] = 6;
v[5] = 8;
vector<int> v(6);
v[0] = 5;
v[4] = 6;
v.push_back(8);

vector<int> w = {5, 7, 9, 4, 6, 8}; // C++11 or higher
vector<int> v2(6, 999);
cout << v2[0];

vector<string> philosopher(4);
philosopher [0] = "Kant";
philosopher [1] = "Plato";
philosopher [2] = "Hume";
philosopher [3] = "Kierkegaard";
//philosopher[2] = 99;

vector<double> vd(1000, 1.2);

vector<vector<int> > twod(5);
twod[0].push_back(12);
twod[0].push_back(45);
twod[1].push_back(3);
twod[2].push_back(1);
twod[2].push_back(6);

/*
[12, 45]
[3]
[1, 6]
[]
[]
*/
}
vector<string> w = {"Gholi", "aroosi", "naraft!"};

vector<vector<int>> twod(5);
twod[0].push_back(12);
twod[0].push_back(45);
twod[1].push_back(3);
twod[2] = {1, 6};

/*
[12, 45]
[3]
[1, 6]
[]
[]
*/
}
5 changes: 2 additions & 3 deletions 02_Containers_Iterators/08_Map.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <map>
#include <iostream>

#include <map>
using namespace std;

int main() {
Expand All @@ -19,4 +18,4 @@ int main() {
map<char, int> cc = {{'a', 4}, {'x', 3}, {'i', 1}};
for (auto it2 = cc.begin(); it2 != cc.end(); it2++)
cout << it2->first << "->" << it2->second << endl;
}
}

0 comments on commit c98abb1

Please sign in to comment.