MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

Java/Stack/reverseasttring.cpp:30–81  ·  view source on GitHub ↗

Driver Code

Source from the content-addressed store, hash-verified

28
29// Driver Code
30int main()
31{
32
33 // push elements into
34 // the stack
35 st.push(1);
36 st.push(2);
37 st.push(3);
38 st.push(4);
39
40 cout<<"Original Stack"<<endl;
41
42 // print the elements
43 // of original stack
44 vector<int>v;
45 while(!st.empty())
46 {
47 int p=st.top();
48 st.pop();
49 v.push_back(p);
50 }
51
52 //display of reversed stack
53 for(int i=0;i<v.size();i++){
54 cout<<v[i]<<" ";
55 }
56 st.push(1);
57 st.push(2);
58 st.push(3);
59 st.push(4);
60
61 // function to reverse
62 // the stack
63 reverse();
64 cout<<"\nReversed Stack"
65 <<endl;
66
67 // storing values of reversed
68 v.clear();
69 while(!st.empty())
70 {
71 int p=st.top();
72 st.pop();
73 v.push_back(p);
74 }
75
76 //display of reversed stack
77 for(int i=0;i<v.size();i++){
78 cout<<v[i]<<" ";
79 }
80 return 0;
81}

Callers

nothing calls this directly

Calls 7

topMethod · 0.80
push_backMethod · 0.80
reverseFunction · 0.70
pushMethod · 0.45
popMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected