0% found this document useful (0 votes)
19 views

Project in Data Structure

The document discusses a project on data structures and algorithms using stacks. It presents code to design a menu interface and push and pop elements into a stack data structure.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Project in Data Structure

The document discusses a project on data structures and algorithms using stacks. It presents code to design a menu interface and push and pop elements into a stack data structure.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Project in Data

Structure & Algorithms


(STACK)

Presented by:
Rafael Angelo T. Constantino

BTVTED-CP2
#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <stack>
using namespace std;

COORD coord = {0,0};

void gotoxy (int x, int y)


{
coord.X=x;
coord.Y=y;

SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}

char corner1 = 195;


void design1()
{
for (int xx=0; xx<80; xx++){
for (int yy=0; yy<26; yy++){
gotoxy(xx,yy);cout<<corner1;
}}
}

void design2()
{
for (int xx=10; xx<60; xx++){
for (int yy=5; yy<16; yy++){
gotoxy(xx,yy);cout<<" ";
}}
}

char corner3 = 176;


void design3()
{
for (int xx=12; xx<62; xx++){
for (int yy=6; yy<17; yy++){
gotoxy(xx,yy);cout<<corner3;
}}
}

//Design 4
void design4()
{
for (int xx=10; xx<60; xx++){
for (int yy=18; yy<24; yy++){
gotoxy(xx,yy);cout<<" ";
}}
}

//Design 5
char corner5 = 172;//Change design
void design5()
{
for (int xx=12; xx<62; xx++){
for (int yy=19; yy<25; yy++){
gotoxy(xx,yy);cout<<corner5;
}}
}

int arry[5];
int ctr=0;
int main()
{
design1();
design3();
design2();
design5();
design4();
stack<int> myStack;
int mnum;
int data;

gotoxy(10,6);cout<<" >>>Menu<<<";
gotoxy(10,8);cout<<" 1. PUSH.."<<endl;
gotoxy(10,9);cout<<" 2. POP!.."<<endl;
gotoxy(10,10);cout<<" 3. EXIT.."<<endl;
gotoxy(10,18);cout<<" |||STACK|||";
do{
gotoxy(10,12);cout<<" Enter a number: ";
cin>>mnum;

switch(mnum)
{
case(1):
gotoxy(10,19);cout<<" Enter an element: ";
cin>>data;
arry[ctr]=data;
myStack.push(data);
ctr++;

gotoxy(10,20);for (int x=0; x<5; x++){


cout<<arry[x]<<"\t";}
cout<<"PUSHED..";
break;
case(2):
gotoxy(10,21);for (int x=0; x<5; x++){
ctr--;
arry[ctr]=0;
myStack.pop();
cout<<arry[ctr]<<"\t";}
cout<<"POPPED!..";
break;

case(3):
gotoxy(10,19);cout<<" <|>Exit<|>... ";
system("cls");
exit(1);
}
}while(1);

You might also like