Generation

generate functionFri, 19 May 2023

Escribir un programa que calcule el producto de la matriz A por el vector v. "a"=8 "b"=7 "c"=5 Donde la matriz A es: 3a 3 3c 4b 9 8a 7 5c 2c y el vector v es: 8c 1 4b Luego escribir una función para: 1) Si "a" toma valores de 0 a 5, hallar el menor elemento del vector resultante 2) Si "a" toma valores de 6 a 9, hallar el mayor elemento del vector resultante. Mostrar el resultado por pantalla del producto y del menor o mayor valor.

#include <iostream> //For cout #include <vector> //For vectors #include <algorithm> //For sort //First define a function that multiplies a matrix by a vector //This function is not the homework, it is just for convenience std::vector<int> multiply(std::vector<std::vector<int>> matrix, std::vector<int> vector) { //Make an output vector of the correct size std::vector<int> output(vector.size(), 0); //Loop through the rows of the matrix for(int i = 0; i < matrix.size(); i++) { //Loop through the columns of the matrix for(int j = 0; j < matrix[0].size(); j++) { //Add the product to the output output[i] += matrix[i][j] * vector[j]; } } //Return the result return output; } int main() { //Define matrix A std::

Questions about programming?Chat with your personal AI assistant