list[1].c++
list[1].c++
#include <iostream>
#include <list>
#include <algorithm> // For sort
int main()
{
// 1. Declaration and Initialization
cout << "1. Declaration and Initialization" << endl;
// 2. Insertion
cout << "2. Insertion" << endl;
// 3. Deletion
cout << "3. Deletion" << endl;
// 4. Accessing Elements
cout << "4. Accessing Elements" << endl;
cout << "Accessing elements using a range-based loop: ";
for (int value : numbers1)
{
cout << value << " ";
}
cout << endl
<< endl;
2. Insertion
Inserted 0 at the beginning: 0 1 2 3 4 5
Inserted 6 at the end: 0 1 2 3 4 5 6
Inserted 42 at the 3rd position: 0 1 2 42 3 4 5 6
3. Deletion
Deleted the first element: 1 2 42 3 4 5 6
Deleted the last element: 1 2 42 3 4 5
Deleted the 3rd element: 1 2 3 4 5
4. Accessing Elements
Accessing elements using a range-based loop: 1 2 3 4 5