formatting source-code for 153fb7b8a5

This commit is contained in:
github-actions
2020-05-30 04:02:09 +00:00
parent 92fe9495ec
commit 8a2de9842b
175 changed files with 1671 additions and 3460 deletions

View File

@@ -4,69 +4,50 @@ using namespace std;
int *stack;
int top = 0, size;
void push(int x)
{
if (top == size)
{
void push(int x) {
if (top == size) {
cout << "\nOverflow";
}
else
{
} else {
stack[top++] = x;
}
}
void pop()
{
if (top == 0)
{
void pop() {
if (top == 0) {
cout << "\nUnderflow";
}
else
{
} else {
cout << "\n" << stack[--top] << " deleted";
}
}
void show()
{
for (int i = 0; i < top; i++)
{
void show() {
for (int i = 0; i < top; i++) {
cout << stack[i] << "\n";
}
}
void topmost() { cout << "\nTopmost element: " << stack[top - 1]; }
int main()
{
int main() {
cout << "\nEnter Size of stack : ";
cin >> size;
stack = new int[size];
int ch, x;
do
{
do {
cout << "\n1. Push";
cout << "\n2. Pop";
cout << "\n3. Print";
cout << "\n4. Print topmost element:";
cout << "\nEnter Your Choice : ";
cin >> ch;
if (ch == 1)
{
if (ch == 1) {
cout << "\nInsert : ";
cin >> x;
push(x);
}
else if (ch == 2)
{
} else if (ch == 2) {
pop();
}
else if (ch == 3)
{
} else if (ch == 3) {
show();
}
else if (ch == 4)
{
} else if (ch == 4) {
topmost();
}
} while (ch != 0);