Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #define maxsize 10
- using namespace std;
- struct history{
- string url;
- string time;
- }history[maxsize];
- int top = -1;
- int isempty() {
- if(top == -1)
- return 1;
- else
- return 0;
- }
- int isfull() {
- if(top == maxsize)
- return 1;
- else
- return 0;
- }
- void pop() {
- string data;
- if(!isempty()) {
- data = history[top].url;
- top = top - 1;
- cout << "Data " << data;
- } else {
- cout << "data penuh";
- }
- }
- void push(string url, string time) {
- if(!isfull()) {
- top = top + 1;
- history[top].url = url;
- history[top].time = time;
- cout << "Anda telah mengakses : " << url << " " << time;
- } else {
- cout << "data penuh";
- }
- }
- int main() {
- int menu;
- do{
- system("cls");
- for(int i=0;i<top;i++){
- cout << history[i].url << " " << history[i].time<<endl;
- }
- cout << endl;
- cout << "1. push" << endl;
- cout << "2. pop" << endl;
- cout << "3. keluar" << endl;
- cout << "masukkan menu : ";
- cin >> menu;
- if(menu == 1) {
- string url,time;
- system("cls");
- cout << "masukkan url : ";
- cin >> url;
- cout << "masukkan time : ";
- cin >> time;
- push(url,time);
- cout << endl;
- system("pause");
- }else if(menu == 2){
- pop();
- }
- }while(menu!=3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement