Untitled
unknown
c_cpp
4 years ago
777 B
4
Indexable
#include <stdio.h> #define X 3 #define Y 3 // Inputs a matrix of x*y size from the console void GetMatrix(int** mat, int x, int y) { for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) scanf("%d", &mat[i][j]); } } // Adds the second matrix to the first one void AddMatrices(int** mat0, int** mat1, int x, int y) { for (int i = 0; i < x; i++) for (int j = 0; j < x; j++) mat0[i][j] += mat1[i][j]; } // Subtracts the second matrix from the first one void SubMatrices(int** mat0, int** mat2) // Multiplies a matrix by a scalar void ScalarMultMatrix(int** mat, int coeff) { for (int i = 0; i < x; i++) for (int j = 0; j < x; j++) mat[i][j] *= coeff; } int main() { int mat0[X][Y]; int mat1[X][Y]; GetMatrix(mat0, X, Y); GetMatrix(mat1, X, Y); }
Editor is loading...