1.头文件:tup.h,包含定义稀疏矩阵的三元组表示数据结构的代码、宏定义、要实现算法的函数的声明;
#define M 6
#define N 7
#define MaxSize 100 //矩阵中非零元素最多个数
typedef int ElemType;
typedef struct
{
int r; //行号
int c; //列号
ElemType d; //元素值
} TupNode; //三元组定义
typedef struct
{
int rows; //行数
int cols; //列数
int nums; //非零元素个数
TupNode data[MaxSize];
} TSMatrix; //三元组顺序表定义
void CreatMat(TSMatrix &t,ElemType A[M][N]); //从一个二维稀疏矩阵创建其三元组表示
bool Value(TSMatrix &t,ElemType x,int i,int j); //三元组元素赋值
bool Assign(TSMatrix t,ElemType &x,int i,int j); //将指定位置的元素值赋给变量
void DispMat(TSMatrix t);//输出三元组
void TranTat(TSMatrix t,TSMatrix &tb);//矩阵转置
2.源文件:tup.cpp,包含实现各种算法的函数的定义
#include "stdio.h"
#in