Question & Answer: Write a function named "make_mult_table" that takes an integer (denoting the max_factor) and returns a vector of…..

Write a function named “make_mult_table” that takes an integer (denoting the max_factor) and returns a vector of vectors of longs representing a multiplication table from 0 to (and including) max_factor.

Example:

max_factor = 3

Return value:

{ {0, 0, 0, 0},
  {0, 1, 2, 3},
  {0, 2, 4, 6},
  {0, 3, 6, 9},  }

Write atunction named make mult table that takes an integer (denotIng the max tactor and returns a vector or vectors of longs representing a multiplication table from 0 to (and Includng) max toctor. Example: actor 33 Retum volue 10, 0,0. 1, 2, 3, using std vector 4 vector vector Long make mult table(Long max factor) Your code here Test Cases 001: Max-factor of 3 001: Other Max Factor Not Run 003: Hidden Unit Testcase Unit Testcase Unit Testcase Save 6 Run Tests Details Details Detailsuse c++

Expert Answer

 #include <iostream>

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

vector<vector < long > > make_mult_table(long max_factor){
vector<vector < long > > vec;
for(int i=0;i<=max_factor;++i){

vector<long>v;
for(int j=0;j<=max_factor;++j){
v.push_back(i*j);

}
vec.push_back(v);

}
return vec;
}
int main()
{
vector< vector < long > > vec = make_mult_table(3);

for (int i = 0; i < vec.size(); i++)
{
cout<<endl;
for (int j = 0; j < vec[i].size(); j++)
{
cout << vec[i][j] <<” “;
}
}
return 0;
}
=====================================================
See Output

Still stressed from student homework?
Get quality assistance from academic writers!