-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstackassignment7.cpp
More file actions
73 lines (70 loc) · 1.71 KB
/
Copy pathstackassignment7.cpp
File metadata and controls
73 lines (70 loc) · 1.71 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
#include<iostream>
using namespace std;
class history{
string sites[5];
string nextsite[5];
int top,top1,top2;
public:
history(){
top1=-1;
top2=-2;
top=top2;
}
void visitedpage(string link){
if(top1<5){
top1++;
sites[top1]=link;
}
}
void negativeBack(){
if(top1<0){
cout<<"Stack is underflow"<<endl;
}
top2++;
nextsite[top2] = sites[top1];
top1--;
cout<< sites[top1] <<endl;
}
void viewcurrentpage(){
cout<<nextsite[top]<<endl;
}
void EmptyHist(){
if(top1<0){
cout<<"No History ";
}
else{
printHistory1();
}
}
void printHistory1(){
for (int i =0;i<=top1;i++){
cout<<sites[i]<<endl;
}
}
void printHistory2(){
for(int i=0;i<=top2;i++){
cout<<nextsite[i]<<endl;
}
}
};
int main(){
history H1;
H1.visitedpage("Netflix.com");
H1.visitedpage("YT.com");
H1.visitedpage("Google.com");
H1.visitedpage("amazon.com");
H1.visitedpage("leetcode.in");
cout<<"resent history"<<endl;
H1.printHistory1();
cout<<"nevigated page"<<endl;
H1.negativeBack();
cout<<"nevigated page"<<endl;
H1.negativeBack();
cout<<"nevigated page"<<endl;
cout<<"history 2"<<endl;
H1.printHistory2();
cout<<"current page"<<endl;
H1.viewcurrentpage();
cout<<"check the history is empty or not "<<endl;
H1.EmptyHist();
}