Test List

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Test List as PDF for free.

More details

  • Words: 266
  • Pages: 2
/* This program is used to demonstrate the linked list data structure and its operations. The program allows the user to pick the operation that he/she wants to apply to the list. */ #include "LinkedList.h" #include using namespace std; int main() { int position; //stores the position of insertion/deletion int value; //stores the data value to be inserted char operation; //stores the operation (insert, delete, print) LinkedList L1;//creates a linked list of type integer cout << "This program demonstrates the linked list data structure and its operations." << "\nThe list capacity is 10." << endl; cout << "--------------------------------------------------------------------------------" <<endl; cout << "The program starts with one node" << endl; L1.Insert(2); position does not

//insert first element. by default the position is 1 //note that when we insert for the first time the value of //matter as you can see in the definition of Insert

L1.print();//print list cout << "--------------------------------------------------------------------------------" <<endl; cout<<endl; //loop as much as the user wishes do { cout<<"\nEnter i to insert, d to delete, p to print the list, and x to exit: "<<endl; cout<<"==================================================================="<<endl; cin>>operation; if(operation=='i') //if user chooses insert { //notify user about the index of list nodes cout<<"\nNote that the first node is considered to be at position 1."<<endl; cout<<"Enter the value then the position where you want to insert: "; cin>>value>>position; L1.Insert(value, position);

} else if(operation=='d') //if user chooses delete { cout<<"\nEnter the position of the node you want to delete: "; cin>>position; L1.Delete(position); } else if(operation=='p') //if user chooses print { L1.print(); cout << "--------------------------------------------------------------------------------" <<endl; } }while(operation !='x'); //end of do while return 0;//end main }

Related Documents

Test List
May 2020 5
Ma Test List
May 2020 0
Lab Test List
December 2019 21
98b Test List
April 2020 6
Test Test Test
May 2020 76