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