[C++] 구조체로 표현한 희소행렬과 두 행렬의 덧셈과 전치
희소행렬간의 덧셈과 전치#include #include using namespace std;#define MAX_TERMS 100typedef struct { int row; int col; int value;} element;typedef struct Matrix{ vector data; int rows; int cols; int terms; // 생성자에서 data를 MAX_TERMS로 초기화 Matrix() : data(MAX_TERMS), rows(0), cols(0), terms(0) {}} matrix;Matrix matrix_transpose2(Matrix &a) { matrix b; //b 행렬을 a의 전치행렬 형태로 //0이..