-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathArray_Stl.cpp
More file actions
59 lines (59 loc) · 1.53 KB
/
Array_Stl.cpp
File metadata and controls
59 lines (59 loc) · 1.53 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
#include <iostream>
#include <array>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
array<int, 5> arr;
array<int, 5>::iterator it;
int choice, item;
arr.fill(0);
int count = 0;
while (1)
{
cout<<"\n---------------------"<<endl;
cout<<"Array Implementation in Stl"<<endl;
cout<<"\n---------------------"<<endl;
cout<<"1.Insert Element into the Array"<<endl;
cout<<"2.Size of the array"<<endl;
cout<<"3.Front Element of Array"<<endl;
cout<<"4.Back Element of Array"<<endl;
cout<<"5.Display elements of the Array"<<endl;
cout<<"6.Exit"<<endl;
cout<<"Enter your Choice: ";
cin>>choice;
switch(choice)
{
case 1:
cout<<"Enter value to be inserted: ";
cin>>item;
arr.at(count) = item;
count++;
break;
case 2:
cout<<"Size of the Array: ";
cout<<arr.size()<<endl;
break;
case 3:
cout<<"Front Element of the Array: ";
cout<<arr.front()<<endl;
break;
case 4:
cout<<"Back Element of the Stack: ";
cout<<arr.back()<<endl;
break;
case 5:
for (it = arr.begin(); it != arr.end(); ++it )
cout <<" "<< *it;
cout<<endl;
break;
case 6:
exit(1);
break;
default:
cout<<"Wrong Choice"<<endl;
}
}
return 0;
}