#include<malloc.h>
#include<iostream>
using namespace std;
typedef struct {
int row, col;
int data;
}TruNode;
#define MAX_NUM 1024
typedef struct {
int rows, cols;
int num;
TruNode datas[MAX_NUM];
} TRUMATRIX;
TRUMATRIX* InputMatrix(TRUMATRIX*A);
void Output(TRUMATRIX*A);
int ElementMatrix(TRUMATRIX *pMtr, int row, int col);
TRUMATRIX* AddMatrix(TRUMATRIX *pMtr1, TRUMATRIX *pMtr2, TRUMATRIX *pMtr3);
TRUMATRIX* TransMatrix(TRUMATRIX *pMtr1, TRUMATRIX *pMtr2);
TRUMATRIX* Init();
void main()
{
TRUMATRIX*A = Init();
TRUMATRIX*B = Init();
TRUMATRIX*C = Init();
int row, col, data;
int op;
while (1)
{
cout << "1:输入矩阵 2:输出矩阵 3:矩阵的加法 4:取矩阵元素 5:矩阵转置 0:退出" << endl;
cin >> op;
switch (op)
{
case 1:
A = InputMatrix(A);
Output(A);
break;
case 2:
Output(A);
break;
case 3:
B = InputMatrix(B);
C = AddMatrix(A, B, C);
Output(C);
break;
case 4:
cout << "请输入所取元素的行和列" << endl;
cin >> row >> col;
data = ElementMatrix(A, row, col);
cout << "该元素为:" << data << endl;
break;
case 5:
B = TransMatrix(A, B);
Output(B);
break;
case 0:
return;