Standard Template Library assignment Part I: Container exercise · Create a vector, list, stack, map, and set (the last two can be ordered or unordered) · Add 10 elements to each one (manually or using...

1 answer below »
It's a c++ homework.


Standard Template Library assignment Part I: Container exercise · Create a vector, list, stack, map, and set (the last two can be ordered or unordered) · Add 10 elements to each one (manually or using a loop) · Remove the 3rd element from each one · Print each one. Use each kind of loop (index-based, range-based, iterator-based) at least once. Restore the stack so it is unchanged. Part II: Algorithms exercise · Implement three of the functions in  · Make a copy of one of the containers you filled in Part I. · Call each of the algorithms you implemented on one of the containers. Call the corresponding STL algorithm on the other container. Each time, show that your implementation works the same as the STL implementation. The sequence should be · call your function f1 on container A · call std::f1 on container B · show that A and B are the same · call your function f2 on container A · call std::f2 on container B · show that A and B are the same · etc.
Answered 1 days AfterApr 22, 2021

Answer To: Standard Template Library assignment Part I: Container exercise · Create a vector, list, stack, map,...

Kshitij answered on Apr 23 2021
143 Votes
C+++++/1stAssignment.cpp
C+++++/1stAssignment.cpp
/*
*   Created by CLion IDE.
*   Author: Kshitij Varshney (kshitijvarshne1)
*   Date: 23-Ap
r-21
*   Time: 12:07 PM
*   File: aa.cpp
*/
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# define modValue 1e9 + 7
# define ll long long int
# define cin ios_base::sync_with_stdio(false);cin.tie(NULL); cin
using namespace std;
int main() {
    // create 4 stl
    vector v;
    stack s;
    map m;
    set se;
    // insert 10 values from user
    for (int i = 0; i < 10; i++) {
        int x;
        cin >> x;
        v.push_back(x);
        s.push(x);
        m.insert({i, x});
        se.insert(x);
    }
    for (auto ve:v) {
        cout << ve << " ";
    }
    cout << endl;
    // delete the value from vector v from 3 position
    v. erase(v. begin() + 3 );
    for (auto ve:v) {
        cout << ve << " ";
    }
    cout << endl;
    for (auto e:se) {
        cout << e << " ";
    }
    cout<    int c=0;
    //delete the value from vector v from 3 position
    for(auto it= se.begin();it!=se.end();it++){
        c+=1;
        if(c==3){
            se.erase(it);
          ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here