Answers for "c++ vector of inputs"

C++
5

taking user input for a vector in c++

vector<int> g1;
for(i=0;i<n;i++)
{
  cin>>a;
  g1.push_back(a);
}
Posted by: Guest on June-11-2021
0

how to fill vector from inputs c++

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

int main()
{
  vector<int> a;
  int SIZE = 5;
  
  for(int i = 0; i < N; i++)
  {
    int tmp;
    cin >> tmp;
    a[i] = tmp;
  }
}
Posted by: Guest on November-19-2021

Browse Popular Code Answers by Language