pro
1492.稀疏矩阵的乘法
时限:1000ms 内存限制:10000K 总时限:3000ms
描述
计算两个稀疏矩阵的乘法
输入
首先输入第一个矩阵的行数和列数,再输入该矩阵的三元组形式,以0 0 0结束
然后输入第二个矩阵的行数和列数,再输入该矩阵的三元组形式,以0 0 0结束
输出
两个矩阵相乘后得到的矩阵的三元组形式
输入样例
3 3
1 1 1
2 2 2
2 3 4
3 1 -4
0 0 0
3 3
1 3 -2
2 3 -5
3 1 8
3 2 -6
0 0 0
输出样例
1 3 -2
2 1 32
2 2 -24
2 3 -10
3 3 8
# include <iostream>
# include <cstdio>
# include <cmath>
# include <cctype>
# include <vector>
# include <string>
# include <cstring>
# include <algorithm>
using namespace std;
# define Elemtype int
# define MAXSIZE 1000
//typedef struct triple
//{
// //声明一个三元组
// int i;
// int j;
// Elemtype data;
//}triple, * Ptriple;
//typedef struct
//{
// triple data[MAXSIZE];
// int iu, ju, tu;
//}trimatrix, * Ptrimatrix;
typedef struct OLNo