stack c++
stack<int> stk;
stk.push(5);
int ans = stk.top(5); // ans =5
stk.pop();//removes 5
stack c++
stack<int> stk;
stk.push(5);
int ans = stk.top(5); // ans =5
stk.pop();//removes 5
stack erase
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
main() {
struct node {
int data;
struct node *next;
}*pNew,*dltPtr;
struct stack_ptr {
int count;
struct node *top;
}*stack;
int i;
scanf("%d",&i);
pNew = new node;
pNew->data = i;
pNew->next = NULL;
stack = new stack_ptr;
stack->count = 1;
stack->top = pNew;
scanf("%d",&i);
while (i != 0){
pNew = new node;
pNew->data = i;
pNew->next = stack->top;
stack->count++;
stack->top = pNew;
scanf("%d",&i);
}
dltPtr = stack->top;
while (dltPtr != NULL) {
printf("% d",dltPtr->data);
dltPtr = dltPtr->next;
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us