static void Main(string[] args) { int choice, data, x; CircularLinkedList list = new CircularLinkedList(); list.CreateList(); while (true) { Console.WriteLine("1. Display List "); Console.WriteLine("2. Insert in empty list"); Console.WriteLine("3. Insert a node in beginning of the list"); Console.WriteLine("4. Insert a node at the end of the list"); Console.WriteLine("5. Insert a node after a specified node"); Console.WriteLine("6. Delete first node"); Console.WriteLine("7. Delete last node"); Console.WriteLine("8. Delete a specified node"); Console.WriteLine("9. Exit program"); Console.WriteLine("Enter your choice: "); choice = Convert.ToInt32(Console.ReadLine()); if (choice == 9) { break; } switch (choice) { case 1: // Display current list list.DisplayList(); break; case 2: // Insert node to empty list Console.Write("Enter the element to be inserted: "); data = Convert.ToInt32(Console.ReadLine()); list.InsertInEmptyList(data); break; case 3: // Insert node at beginning of list Console.Write("Enter the element to be inserted: "); data = Convert.ToInt32(Console.ReadLine()); list.InsertInBeginning(data); break; case 4: // Insert node at end of list Console.Write("Enter the element to be inserted: "); data = Convert.ToInt32(Console.ReadLine()); list.InsertAtEnd(data); break; case 5: // Insert a node after specifed node Console.Write("Enter the element to be inserted: "); data = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter the element after which to insert: "); x = Convert.ToInt32(Console.ReadLine()); list.InsertAfter(data, x); break; case 6: // Delete first node list.DeleteFirstNode(); break; case 7: // Delete last node list.DeleteLastNode(); break; case 8: // Delete node with specified data Console.Write("Enter the element to be deleted: "); data = Convert.ToInt32(Console.ReadLine()); list.DeleteNode(data); break; case 9: // break; } } }
static void Main(string[] args) { int choice, data, x; CircularLinkedList list = new CircularLinkedList(); while (true) { Console.WriteLine("1.Display the list"); Console.WriteLine("2.Insert in empty list"); Console.WriteLine("3.Insert in the beginning"); Console.WriteLine("4.Insert at the end"); Console.WriteLine("5.Insert after a node"); Console.WriteLine("6.Delete first node"); Console.WriteLine("7.Delete last node"); Console.WriteLine("8.Delete any node"); Console.WriteLine("9.Quit"); Console.WriteLine("Enter your choice:"); choice = Convert.ToInt32(Console.ReadLine()); if (choice == 9) { break; } switch (choice) { case 1: list.DisplayList(); break; case 2: Console.Write("Enter the element to be inserted"); data = Convert.ToInt32(Console.ReadLine()); list.InsertInEmptyList(data); break; case 3: Console.Write("Enter the element to be inserted:"); data = Convert.ToInt32(Console.ReadLine()); list.InsertInBeginning(data); break; case 4: Console.Write("Enter the element to be inserted:"); data = Convert.ToInt32(Console.ReadLine()); list.InsertAtEnd(data); break; case 5: Console.Write("Enter the element to be inserted: "); data = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter the element after which to insert:"); x = Convert.ToInt32(Console.ReadLine()); list.InsertAfter(data, x); break; case 6: list.DeleteFirstNode(); break; case 7: list.DeleteLastNode(); break; case 8: Console.Write("Enter the element to be deleted:"); data = Convert.ToInt32(Console.ReadLine()); list.DeleteNode(data); break; default: Console.WriteLine("Wrong choice"); break } Console.WriteLine(); } Console.WriteLine("Exiting"); }
static void Main(string[] args) { int choice, data, x; CircularLinkedList CList = new CircularLinkedList(); CircularLinkedList clist2 = new CircularLinkedList(); CList.CreatList(); clist2.CreatList(); while (true) { Console.WriteLine("1. Display list"); Console.WriteLine("2. Insert in empty list"); Console.WriteLine("3. Insert in the beginning"); Console.WriteLine("4. Insert in the end"); Console.WriteLine("5. Insert after a node"); Console.WriteLine("6. Delete first node"); Console.WriteLine("7. Delete last node"); Console.WriteLine("8. Delete any node"); Console.WriteLine("9. concatnate"); Console.WriteLine("10. Quit"); Console.Write("Enter your choice: "); choice = Convert.ToInt32(Console.ReadLine()); if (choice == 10) { break; } switch (choice) { case 1: Console.WriteLine("one"); CList.DisplayList(); Console.WriteLine("two"); clist2.DisplayList(); break; case 2: Console.Write("Enter the element to be inserted: "); data = Convert.ToInt32(Console.ReadLine()); CList.InsertInEmptyList(data); break; case 3: Console.Write("Enter the element to be inserted: "); data = Convert.ToInt32(Console.ReadLine()); CList.InsertInBeginning(data); break; case 4: Console.Write("Enter the element to be inserted: "); data = Convert.ToInt32(Console.ReadLine()); CList.InsertAtEnd(data); break; case 5: Console.Write("Enter the element to be inserted: "); data = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter the element after which to be inserted: "); x = Convert.ToInt32(Console.ReadLine()); CList.InsertAfter(data, x); break; case 6: CList.DeleteFirstNode(); break; case 7: CList.DeleteLastNode(); break; case 8: Console.Write("Enter an element to be deleted it: "); data = Convert.ToInt32(Console.ReadLine()); CList.DeleteNode(data); break; case 9: Console.Write("concatnate two Clist"); CList.Concatenate(clist2); CList.DisplayList(); break; default: Console.WriteLine("Wrong Choice"); break; } Console.WriteLine(); } Console.WriteLine("Exiting"); }