List of C ++ STL, stllist
# Include <bits/stdc ++. h> using namespace std; int main () {// use the list container to process integer data list <int> l1; // declare it as the iterator list <int> :: iterator it; // previously added data l1.push _ front (2) to the l1 container; l1.push _ front (1 ); // Add data l1.push _ back (3) and l1.push _ back (4) to the l1 container ); // data 1 2 3 4 for (it = l1.begin (); it! = L1.end (); it ++) cout <* it <""; cout <endl; // display l1 data 4 3 2 1 list <int>: reverse_iterator ir; for (ir = l1.rbegin (); ir! = L1.rend (); ir ++) cout <* ir <""; cout <endl; // use STL accumulate (accumulate) algorithm int result = accumulate (l1.begin (), l1.end (), 0); // 0 is the initial value of cout <"Sum =" <result <endl; cout <"----------------" <endl; // -------------------------- // use the list container to process sorted data list <char> l2; // declare ir as the iterator list <char>: iterator itt; // Add data l2.push _ front ('B') to the l2 container '); l2.push _ front ('A'); // Add data from the back to the l2 container L2.push _ back ('C'); l2.push _ back ('D'); // displays data in l2 from the front to the back // a B C D for (itt = l2.begin (); itt! = L2.end (); itt ++) cout <* itt <""; cout <endl; // use The max_element algorithm of STL to calculate The maximum element in listTwo and display The following: itt = max_element (l2.begin (), l2.end (); cout <"The maximum element in l2 is: "<* itt <endl; cout <" ---------------- "<endl ;}