CodeurJava
Java
Collections Java
C/C++
Javascript
Php
Python
Text/ASCII Converter
How to Browse a HashMap in Java
Java Socket: Create a Client/Server Chat Application
How to display prime numbers in C
Minimum and maximum of an array in Java
Current Date and Time in Java
Finding the maximum of a painting and its position in C
The Vector class of java
Calculate the average of an array of integers in C
Averaging an array in Java
Checking if a number is even or odd in C
Sorting by selection in C
Recursive Calculation of PGCD in C Language
How to Reverse an Array Recursively in C Language
Apache POI: Create, read, and edit an Excel file in java
Finding all divisors of an integer in C
JavaScript - onClick method
Calculating the recursive factorial of an integer in C
Hanoi Towers in C algorithm
Browse an array with jQuery.each()
Algorithm - Deleting an item from a contiguous list(array)
C-Bubble Sorting
How to Browse a HashSet in Java
Insertion sorting in C
Function of constructing a paschal triangle in C
jQuery - click() method
Deleting a Value in an Array in C
Regex - Validating an email address in JavaScript
Solving a first-degree equation in C
How to Sort a HashMap by Keys in Java
Matrix calculus in C++ - product of a matrix by a vector
using namespace std;
#include< stdio.h>
#include< stdlib.h>
#include < iostream>
int * product (int **M, int *V, int N)
{
int *Vp = new int[N];
for(int i =
0
; i < N; i++)
Vp[i]=0;
for(int i =
0
; i < N; i++) {
for(int j =
0
; j < N; j++)
Vp[i] += M[i][j] * V[j];
}
return Vp;
}
void display(int **Mat, int N, int M){
for(int i =
0
; i < N; i++) {
for(int j =
0
; j < M; j++) {
Cost < < Mat[i][j];
Cost < <
"\t"
;
}
Cost < <
"\n"
;
}
Cost < <
"\n"
;
}
int main(int argc, char *argv[])
{
int n=
3
;
int** M = new int* [ n ];
for (int i=
0
; i < n; i++)
M[i] = new int[ n ];
srand(time(NULL));
for(int i=
0
; i< n; i++)
for(int j=
0
; j< n; j++)
M[i][j] =rand()%
10
;
display(M,n,n);
int V[
3
] = {
2
,
6
,
3
};
Cost < <
"\n V = [ "
;
for(int i =
0
; i < n; i++)
Cost < <
" "
< < V[i]< <
" "
;
Cost < <
" ] "
;
int *Vp = product(M,V,n);
Cost < <
"\n Vp = [ "
;
for(int i =
0
; i < n; i++)
Cost < <
" "
< < Vp[i]< <
" "
;
Cost < <
" ] "
;
system(
"pause"
);
}
Advertisement
AdBlock Detected
Please disable your ad blocker and refresh the window to use this website.