Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class ListType{
- int size,length;
- int *list;
- public:
- ListType(int S=100){
- length=0;
- if(S>= 0)
- size=S;
- else size=100;
- list = new int [size];
- for(int i=0;i<S;i++){
- list[i]=0;}
- }
- ~ListType()
- {delete [] list;}
- int getMaxSize()
- {return size;}
- int getLength()
- {return length;}
- bool isEmpty(){
- if (length==0){
- return true;}
- else return false;
- }
- bool isFull(){
- if(length==size){
- return true;}
- else return false;
- }
- void insert(int N){
- for(int i=0;i<size;i++){
- if (list[i]==0)
- { list [i]=N;
- length++;
- break;
- }
- }
- }
- int search(int R){
- for(int i=0;i<size;i++){//or we can change S to L for have more efficiency
- if(R==list[i])
- {return i;}}
- return -1;
- }
- void initialize(){
- delete [] list;
- list =new int [size];
- for(int i=0;i<size;i++){list[i]=0;}
- length=0;
- }
- void print(){
- for(int i=0;i<length;i++){
- cout<<list[i]<<" ";}
- cout<<endl;
- }
- };
- int main() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement