Answers for "product of all elements in vector c++"

C++
3

get values from a vector of vectors c++

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

int main()
{
    vector<vector<int> > buff;

    for(int i = 0; i < 10; i++)
    {
        vector<int> temp; // create an array, don't work directly on buff yet.
        for(int j = 0; j < 10; j++)
            temp.push_back(i); 
 
        buff.push_back(temp); // Store the array in the buffer
    }

    for(int i = 0; i < buff.size(); ++i)
    {
        for(int j = 0; j < buff[i].size(); ++j)
            cout << buff[i][j];
        cout << endl;
    }

    return 0;
}
Posted by: Guest on July-18-2020
0

c++ product of vector

#include <functional> // multiplies
#include <numeric> // accumulate
// ...
std::vector<int> v {2,3,4};
int result = std::accumulate(v.begin(), v.end(), 1, std::multiplies<int>());
Posted by: Guest on February-19-2021

Code answers related to "product of all elements in vector c++"

Browse Popular Code Answers by Language