void main() { int ch; int k,x,len,p; clrscr(); LinearList <int> obj; do { menu(); cout<<"enter choice\t"; cin>>ch; switch(ch) { case 1: len=obj.Length(); if(len==0) cout<<"List is empty\n"; else cout<<"length of linearlist is "<<len<<endl; break; case 2: cout<<"enter k,x(position and value)\n"; cin>>k>>x; p=obj.Find(k,x); if(p==1) cout<<"found"<<endl; if(p==0) cout<<"not found"<<endl; break; case 3: cout<<"enter x(value)\n"; cin>>x; p=obj.Search(x); if(p) cout<<"searching is sucessful and found at"<<p<<endl; else cout<<"searching not sucessful"<<endl; break; case 4: cout<<"enter k,x(position and value)\n"; cin>>k>>x; obj.Delete(k,x); break; case 5: cout<<"enter k,x(index and value)\n"; cin>>k>>x; obj.Insert(k,x); break; case 6: cout<<"elements in the list are:\n\n"; obj.Output(); break; default: cout<<"invalid choice\n"; break; } } while(ch>=1&&ch<=6); getch(); }
int main() { LinearList<int> L; cout<<"Length = "<<L.Length()<<endl; cout<<"IsEmpty = "<<L.IsEmpty()<<endl; cout<<"MaxSize = "<<L.MaxSize()<<endl; L.Insert(0,2); L.Insert(1,6); cout<<"List is "<<L<<endl; cout<<"MaxSize = "<<L.MaxSize()<<endl; cout<<"IsEmpty = "<<L.IsEmpty()<<endl; int z; L.Find(1,z); cout<<"First Element is "<<z<<endl; cout<<"Length is "<<L.Length()<<endl; L.Delete(1,z); cout<<"Deleted Element is "<<z<<endl; cout<<"MaxSize = "<<L.MaxSize()<<endl; cout<<"List is"<<L<<endl; while (true) { } }