Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class dinarr{
- int a[],t;
- dinarr(){
- a=new int[1];
- t=0;
- }
- void _resize(int x){
- int b[]=new int[x];
- for (int i=0;i<x && i<t;++i) b[i]=a[i];
- a=b;
- }
- void _pushb(int x){
- if (t==a.length) _resize(t+t);
- a[t++]=x;
- }
- void _popb(){
- --t;
- }
- int _bck(){
- return a[t-1];
- }
- }
- class vector{
- private dinarr f;
- vector(){
- f = new dinarr();
- }
- vector(int x){
- f = new dinarr();
- if (x<1) x=1;
- f.a=new int[x];
- f.t=0;
- }
- vector(int b[]){
- f = new dinarr();
- f.a=b;
- f.t=b.length;
- }
- public void resize(int x){
- f._resize(x);
- }
- public void push_back(int x){
- f._pushb(x);
- }
- public void pop_back(){
- f._popb();
- }
- public int back(){
- return f._bck();
- }
- public int at(int x){
- if (x<f.t) return f.a[x];
- return 100500;
- }
- public void mod(int x,int y){
- if (x<f.t) f.a[x]=y;
- }
- }
- class stack{
- private dinarr f;
- stack(){
- f = new dinarr();
- }
- public void push(int x){
- f._pushb(x);
- }
- public void pop(){
- f._popb();
- }
- public int top(){
- return f._bck();
- }
- }
- public class geom {
- public static void main(String args[]){
- stack s = new stack();
- s.push(7);
- System.out.println(s.top());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment