// 对三元组的映像特别深,关于此问题,我在输出三元表中的数据中时,用了二维数组,因此被数据结构老师不屑地笑了一顿 哈哈哈。的确,本来就是为了节省空间
// 去保存矩阵中的“有用项”,反而本末倒置地使用起了二维数组。
// 2017/10/15
#include<iostream>
using namespace std;
//--------三元组顺序表示方式----------
#define MAX_SIZE 10000
#define MAX_ROW_SIZE 100
#define MAX_COL_SIZE 100
typedef int ElemType;
class Triple_node{
public:
int i, j; // i j 分别表示非零元素的行标和列标,从1开始计数
ElemType e;
friend istream& operator>>(istream &is, Triple_node &node); // 输入结点
friend ostream& operator<<(ostream &os, const Triple_node &node); // 输出结点
};
istream& operator>>(istream &is, Triple_node &node) // 输入结点
{
cout << "按照(行标,列标,元素值)的格式输入非零元素:\n";
is >> node.i >> node.j >> node.e;
return is;
}
ostream& operator<<(ostream &os, const Triple_node &node)
{
o