-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstl_uses.cpp
More file actions
51 lines (41 loc) · 972 Bytes
/
Copy pathstl_uses.cpp
File metadata and controls
51 lines (41 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>
using namespace std;
void printVector(vector<int> &v)
{
cout << "Vector Values :";
for (int i =0; i<v.size(); i++)
{
cout << v[i] << " ";
}
}
int main ()
{
///pair
pair <int, string> p;
p = make_pair (2, "abc");
cout << p.first <<endl;
cout << p.second <<endl;
///vector
vector <int> v,v2;
v.push_back(5);
v.push_back(5);
v.push_back(5);
cout << v[1] <<endl;
cout << v.size() <<endl;
printVector(v);
v.pop_back(); ///doesn't return anything
///vector of pair
v2 = v; ///copying directly
vector <pair<int,int>> vp;
for (int i =0; i<5; i++)
{
vp.push_back(make_pair(i+1,i+2));
cout << vp[i].first << ", " <<vp[i].second <<endl;
}
cout << vp.size() <<endl;
///filling a vector initially with a certain value
vector <int> vfill(5,100);
cout<< "filled vector : \n";
printVector(vfill);
return 0;
}