-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSTL_Array.cpp
More file actions
85 lines (62 loc) · 1.78 KB
/
STL_Array.cpp
File metadata and controls
85 lines (62 loc) · 1.78 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include<bits/stdc++.h>
// #include<array>// for at(),array
// #include<tuple>//for get<>
using namespace std;
int main()
{
array<int,8>a ={10,30,320,50,60,40,70,80};
cout<<"Arrays Elements are ...."<<endl;
for (int i = 0; i < 8; i++)
cout<<a.at(i)<<" ";
cout<<endl;
// cout<<" "<<get<0>(a);
// cout<<" "<<get<1>(a);
// cout<<" "<<get<2>(a);
// cout<<" "<<get<3>(a);
// cout<<" "<<get<4>(a);
// cout<<" "<<get<5>(a);
// cout<<" "<<get<6>(a);
// cout<<" "<<get<7>(a);
// cout<<endl;
// for (int i = 0; i < 8; i++)
// cout<<" "<<a[i];
// cout<<endl;
cout<<"First elemnet is "<<a.front()<<endl;
cout<<"Last elemnet is "<<a.back()<<endl;
sort(a.begin(),a.end());
cout<<"Sorted array are :"<<endl;
for(int i=0;i<8;i++){
cout<<a[i]<<" ";
}cout<<endl;
array<int,10>arr={1,2,3,4,6};
cout<<"Size of array is "<<arr.size()<<endl;
cout<<"Size of array is "<<arr.max_size()<<endl;
return 0;
}
// #include<bits/stdc++.h>
// using namespace std;
// int main()
// {
// array<int,5>a={10,20,40,30,50};
// // array<int,5>b={40,50,60,70,80};
// array<int,5>b;
// for(int i=0;i<5;i++){
// cin>>b[i];
// }
// a.swap(b);
// cout<<"First Array Elements \n";
// for (int i = 0; i < 5; i++)
// cout<<" "<<a.at(i);
// cout<<endl;
// cout<<"Second Array Elements \n";
// for (int i = 0; i < 5; i++)
// cout<<" "<<b.at(i);
// cout<<endl;
// a.empty()?cout<<"This array is empty":cout<<"This array is not empty"<<endl;
// a.fill(10);
// cout<<"Array a after fill functions ..."<<endl;
// for (int i = 0; i < a.size(); i++)
// cout<<" "<<a[i];
// cout<<endl;
// return 0;
// }