#include #include #include #include #include using namespace std; const int maxn = 105; typedef struct { int col,row,val; //列,行,值 }triple; typedef struct node { int m,n,t; // 行数,列数,不为0数的个数 triple list[maxn]; node() { m = n = t = 0; for(int i=0;i b.list[j].row || (a.list[i].row == b.list[j].row && a.list[i].col > b.list[j].col)) { c.t++; c.list[k++] = b.list[j++]; } else { if(a.list[i].val + b.list[j].val !=0 ) { c.t++; c.list[k].row = a.list[i].row; c.list[k].col = a.list[i].col; c.list[k++].val = a.list[i].val + b.list[j].val; } i++; j++; } } } }