Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
floyd alfa 2
#include <bits/stdc++.h> using namespace std; const int inf = numeric_limits<int>::max(); class Matrix { public: void matrixSize(int a, int b); int getColumn(); int getRow(); void showMatrix(); void fillMatrix(); vector<vector<double>> matrix; vector<vector<char>> matrixA; private: int column; int row; }; void Matrix::matrixSize(int b, int a) { column=a; row=b; matrix.resize(row); matrixA.resize(row); for(int i = 0; i < matrix.size(); i++) { matrix[i].resize(column); matrixA[i].resize(column); } } int Matrix::getColumn() { return column; } int Matrix::getRow() { return row; } void Matrix::showMatrix() { int tam; tam = row; cout << "Matriz de longitudes: \n\n"; for(int i = 0; i < tam; i++) { for(int j = 0; j < tam; j++) { if(matrix[i][j] == inf) cout << "inf "; else cout << matrix[i][j] << " "; } cout << "\n"; } cout << "\nMatriz de nodos antecesores: \n\n"; for(int i = 0; i < tam; i++) { for(int j = 0; j < tam; j++) { cout << matrixA[i][j] << " "; } cout << "\n"; } } void Matrix::fillMatrix() { double in; for(int i = 0; i < row; i++) { for(int j = 0; j < column; j++) { cin >> in; matrix[i][j] = in; } } } Matrix multMatrix(Matrix ma, Matrix mb) { Matrix mr; double suma; int ra = ma.getRow(); int ca = ma.getColumn(); int rb = mb.getRow(); int cb = mb.getColumn(); mr.matrixSize(ra, cb); for(int a = 0; a < ra; a++) { for(int b = 0; b < cb; b++) { suma = 0; for(int i = 0; i < ca; i++) { suma += ma.matrix[a][i]*mb.matrix[i][b]; } mr.matrix[a][b] = suma; } } return mr; } Matrix potMatrix(Matrix a, int pot) { Matrix matrixG; matrixG = a; for(int i = 0; i < pot-1; i++) { matrixG = multMatrix(matrixG, a); } return matrixG; } Matrix inicializarMatrices(Matrix matriz) { int a,b; a = matriz.getColumn(); b = matriz.getRow(); for (int i = 0; i < a ; i++) { for(int j = 0; j < b; j++) { matriz.matrixA[i][j] = char('A' + i); if(matriz.matrix[i][j] == -1) matriz.matrix[i][j] = inf; } } return matriz; } void realizarIteracion(Matrix a, int i, int j) { } int main() { int tam; Matrix matrices; cin >> tam; matrices.matrixSize(tam, tam); matrices.fillMatrix(); matrices = inicializarMatrices(matrices); matrices.showMatrix(); }
run
|
edit
|
history
|
help
0
Tejas choudhari
Days in month database using unordered_map
tasks
Привет Linux
matrix
Building squares using smallest amount of matches
Stats - Central Limit Theorem - Normal Distribution with multiple items
PriQHotel2
Ballin primality test
Binary Search