“vecteur CPP” Réponses codées

C vecteurs

#include <iostream>
#include <vector>
 
int main()
{
    // Create a vector containing integers
    std::vector<int> v = { 7, 5, 16, 8 };
 
    // Add two more integers to vector
    v.push_back(25);
    v.push_back(13);
 
    // Print out the vector
    std::cout << "v = { ";
    for (int n : v) {
        std::cout << n << ", ";
    }
    std::cout << "}; \n";
}
Magnificent Millipede

vecteur CPP

// C++ program to illustrate the
// iterators in vector
#include <iostream>
#include <vector>
  
using namespace std;
  
int main()
{
    vector<int> g1;
  
    for (int i = 1; i <= 5; i++)
        g1.push_back(i);
  
    cout << "Output of begin and end: ";
    for (auto i = g1.begin(); i != g1.end(); ++i)
        cout << *i << " ";
  
    cout << "\nOutput of cbegin and cend: ";
    for (auto i = g1.cbegin(); i != g1.cend(); ++i)
        cout << *i << " ";
  
    cout << "\nOutput of rbegin and rend: ";
    for (auto ir = g1.rbegin(); ir != g1.rend(); ++ir)
        cout << *ir << " ";
  
    cout << "\nOutput of crbegin and crend : ";
    for (auto ir = g1.crbegin(); ir != g1.crend(); ++ir)
        cout << *ir << " ";
  
    return 0;
}
Crazy Cottonmouth

C vecteur

#include <vector>
#include <string>

int main() {
  std::vector<std::string> str_v;
  str_v.push_back("abc");
  str_v.push_back("hello world!!");
  str_v.push_back("i'm a coder.");
  for(auto it = str_v.beigin();it != str_v.end(); it++) {
  	printf("%s\n",it->c_str());
  }
}
Beautiful Bear

vecteurs c

#include <iostream>
#include <vector>
 
using namespace std;

int main()
{
    // Create a vector containing integers
   vector<int> v = { 7, 5, 16, 8 };
 
    v.push_back(25); // Adds 25 to the contents of the vector 
    v.push_back(13); // Adds 13 to the contents of the vector
 
    // Print out the contents of the vector
    cout << "v = { ";
    for (int n : v) {
        std::cout << n << ", ";
    }
    cout << "}; \n";
}
Said HR

vecteur CPP

vector<int> v1;
v1.push_back(10); // adds 10
v1.pop_back(); // removes 10
Fantastic Frog

C vecteur

#include <vector>
#include <iostream>

int main ()
{
    std::vector<int>    v1;        // LINE I
    v1.push_back(10);            // LINE II
    std::cout<<v1.front()<<":"<<v1.back()<<std::endl;        // LINE III
    return 0;
}

//code compiles successfully
Calm Caiman

Réponses similaires à “vecteur CPP”

Questions similaires à “vecteur CPP”

Plus de réponses similaires à “vecteur CPP” dans C++

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code