Search
 
SCRIPT & CODE EXAMPLE
 

CPP

cpp list

#include <algorithm>
#include <iostream>
#include <list>
 
int main()
{
    // Create a list containing integers
    std::list<int> l = { 7, 5, 16, 8 };
 
    // Add an integer to the front of the list
    l.push_front(25);
    // Add an integer to the back of the list
    l.push_back(13);
 
    // Insert an integer before 16 by searching
    auto it = std::find(l.begin(), l.end(), 16);
    if (it != l.end()) {
        l.insert(it, 42);
    }
 
    // Print out the list
    std::cout << "l = { ";
    for (int n : l) {
        std::cout << n << ", ";
    }
    std::cout << "};
";
}
Comment

list in c++

#include <bits/stdc++.h>
using namespace std;
void display(list<int> &lst){
    list<int> :: iterator it;
    for(it = lst.begin(); it != lst.end(); it++){
         cout<<*it<<" ";
    }
}
int main(){
    list<int> list1;
    int data, size;
    cout<<"Enter the list Size ";
    cin>>size;
    for(int i = 0; i<size; i++){
        cout<<"Enter the element of the list ";
        cin>>data;
        list1.push_back(data);
    }
    cout<<endl;
    display(list1);
  return 0;
}

Comment

lists c++

#include<iostream>
#include<list>

using namespace std;

int main() 

{ 
    list<int> l; 

} 
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ replace string 
Cpp :: how to use decrement operator in c++ 
Cpp :: how to convert int to std::string 
Cpp :: c++ hide show console 
Cpp :: how to get length of a file in c++ 
Cpp :: c++ printf char as hex 
Cpp :: print vector of vector c++ 
Cpp :: c++ random number 0 to 1 
Cpp :: Heap pinter c++ 
Cpp :: c++ string contains 
Cpp :: height of bst cpp 
Cpp :: terminal compile c++ 
Cpp :: how to get an element in a list c++ 
Cpp :: c++ sieve of eratosthenes 
Cpp :: how to scan array in c++ 
Cpp :: ray sphere intersection equation 
Cpp :: string in cpp 
Cpp :: min element in stl c++ 
Cpp :: c++ standard library source 
Cpp :: c++ get string between two characters 
Cpp :: c++ triple 
Cpp :: break in c++ 
Cpp :: who to include a library c++ 
Cpp :: overload of << c++ 
Cpp :: c++ create thread 
Cpp :: detect cycle in an undirected graph 
Cpp :: cpp mark getter as const 
Cpp :: c++ add two char together 
Cpp :: convert int to string in c++ 
Cpp :: stack c++ 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =