Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define max 100
- struct stek {
- int top;
- int S[max];
- };
- void initStek(stek* st) {
- st->top = -1;
- }
- bool isEmpty(stek* st) {
- return st->top == -1;
- }
- void pushStek(stek* st, int x) {
- if (st->top == max - 1) {
- cout << "Стек переполнен!!!";
- }
- else {
- st->S[++st->top] = x;
- }
- }
- int popStek(stek* st) {
- return st->S[st->top--];
- }
- void main() {
- stek* st = new(stek);
- initStek(st);
- pushStek(st, 1);
- pushStek(st, 2);
- pushStek(st, 3);
- popStek(st);
- popStek(st);
- popStek(st);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement