C压缩矩阵相加
#include<>
#include<>
#define maxsize 1000//定义非零元的最大数目 typedef struct //定义一个三元组 {
int i, j; //非零元行号、列号
int v; //非零元的值
}Triple;
typedef struct //定义稀疏矩阵
{
Triple data[maxsize]; //三元组表
int m, n, t; //稀疏矩阵行、列数、非零元个数
}TSMatrix;
int main()
{
printf("-------------------Matrix's addition!\n");
TSMatrix M,N;
int flag,a,b;
static int sum[100][100]={0};
=0;
=0;
printf("Input the first Matrix's column and line:");
scanf("%d,%d",&,&);
printf("Input the first Matrix'number:\n");
for(a=0;a<;a++)
{
for(b=0;b<;b++)
{
scanf("%d",&flag);
if(flag!=0)
{
[].i=a;
[].j=b;
[].v=flag;
++;
}
}
}
printf("\n");
printf("Input the second Matrix's column and line:");
scanf("%d,%d",&,&);
printf("Input the second Matrix'number:\n");
for(a=0;a<;a++)
{
for(b=0;b<;b++)
{
scanf("%d",&flag);
if(flag!=0)
{
[].i=a;
[].j=b;
N.
C压缩矩阵相加 来自淘豆网m.daumloan.com转载请标明出处.