| 19 | return this->size; |
| 20 | } |
| 21 | void push(int element) |
| 22 | { |
| 23 | if(this->size == this->capacity) |
| 24 | { |
| 25 | capacity *= 2 ; |
| 26 | int *a = new int[capacity] ; |
| 27 | for(int i=0;i<this->size;i++) |
| 28 | a[i+1] = this->a[i] ; |
| 29 | //delete this->[]a ; |
| 30 | this->a = a ; |
| 31 | delete a ; |
| 32 | this->a[0] = element ; |
| 33 | size++ ; |
| 34 | } |
| 35 | else |
| 36 | { |
| 37 | for(int i=size;i>0;i--) |
| 38 | this->a[i] = this->a[i-1] ; |
| 39 | this->a[0] = element ; |
| 40 | size++ ; |
| 41 | } |
| 42 | } |
| 43 | int top() |
| 44 | { |
| 45 | if(this->size == 0) |
no outgoing calls
no test coverage detected