Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishak798 authored Feb 9, 2024
1 parent 849afe2 commit 4312506
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
51 changes: 51 additions & 0 deletions Lists/list.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <bits/stdc++.h>
using namespace std;
int main()
{
list<int> ls(5);
vector<int> copy(2, 100);
for (auto it = ls.begin(); it != ls.end(); it++)
{
cout << "enter element: ";
cin >> *it; // Dereference the iterator to access the element and read into it
}
ls.erase(next(ls.begin(), 1));
ls.insert(next(ls.begin(), 1), copy.begin(), copy.end());
cout << "list elements : ";
for (auto it : ls) // for each loop
{
cout << it << " ";
}
ls.pop_back();
cout << endl;
cout << "Pop list elements : ";
for (auto it : ls) // for each loop
{
cout << it << " ";
}
cout << endl;
// ls.swap(copy);swap does not work with diffrent container

// cout << "Swap lstor elements : ";
// for (auto it : ls) // for each loop
// {
// cout << it << " ";
// }
ls.clear();
cout << endl;
cout << "Clear list elements : ";
for (auto it : ls) // for each loop
{
cout << it << " ";
}
return 0;
}
/*enter element: 1
enter element: 2
enter element: 3
enter element: 4
enter element: 5
list elements : 1 100 100 3 4 5
Pop list elements : 1 100 100 3 4
Clear list elements :*/
Binary file added Lists/list.exe
Binary file not shown.
1 change: 1 addition & 0 deletions Lists/tempCodeRunnerFile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cout << endl;

0 comments on commit 4312506

Please sign in to comment.