#include <iostream>
#include "stdlib.h"
using namespace std;
class IntStack {
public://1
IntStack() {
}
IntStack(int s);
void Push(int data);
void Pop(int &data);
~IntStack();
void Print();
private:
//2
int *stack;
int pos;
int size;
};
IntStack::IntStack(int s) {
//3
size = s;
stack = new int[size];
pos = 0;
}
IntStack::~IntStack() {
//4
delete[]stack;
}
void IntStack: ush(int data) {
//5
if (pos < size) {
stack[pos++] = data;
} else {
cout << "full" << endl;
exit(0);
}
}
void IntStack: op(int &data) {
//6
if (pos > 0) {
data = stack[pos--];
} else {
cout << "empty" << endl;
}
}
void IntStack: rint() {
int i;
for (i = 0; i < pos; i++)
cout << stack << " ";
}
int main() {
IntStack is(5);
int a[10] = {2, 5, 1, 7, 5, 4, 2, 7, 3, 6};
int i = 0;
int d;
int x;
cin >> x;
while (x != -1) {
if (x == 0) {
is.Push(a);
i++;
} else
is.Pop(d);
cin >> x;
}
is.Print();
return 0;
}
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |