分类: 学习 |
欢迎大家拷贝运用
#include "stdio.h"
#define MAXSIZE 10000
typedef int ElemType;
typedef struct
{ int row,col;
ElemType v;
}Triple;
#define MAXSIZE 10000
typedef int ElemType;
typedef struct
{ int row,col;
/*add part*/
void add(TriTable *A,TriTable *B,TriTable *C)
{ int i,j,k;
if(A->m!=B->m||A->n!=B->n)
{
printf("these two arrey unable to add"); return;}
C->m=A->m;C->n=A->n;
C->t=0;
if(A->t==0&&B->t==0) return;
i=j=k=1;
while(i<=A->t&&j<=B->t)
{
if(A->data[i].row<B->data[j].row)
{ C->data[k]=A->data[i];
i++;k++;
}
else
{ if(A->data[i].row>B->data[j].row)
{ C->data[k]=B->data[j];
j++;k++;
}
else
{ if(A->data[i].col<B->data[j].col)
{ C->data[k]=A->data[i];
i++;k++;
}
else
{ if(A->data[i].col>B->data[j].col)
{ C->data[k]=B->data[j];
j++;k++;
}
else
{ if(A->data[i].v+B->data[j].v!=0)
void add(TriTable *A,TriTable *B,TriTable *C)