
高手帮忙看看这道数据结构的题目哪里出啦问题!感谢在先!
#include<iostream>typedefintElemType;usingnamespacestd;#defineM4#defineM4#defineMaxSi...
#include <iostream>
typedef int ElemType;
using namespace std;
#define M 4
#define M 4
#define MaxSize 16
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,int A[4][4])
{int j,i;
t.rows=4;t.cols=4;t.nums=0;
for(i=0;i<M;i++)
{for(j=0;j<4;j++)
if(A[i][j]!=0)
{t.data[t.nums].r=i;
t.data[t.nums].c=j;
t.data[t.nums].d=A[i][j];
t.nums++;}}}
int main()
{int a[4][4]={{1,0,3,0},{0,1,0,0},{0,0,1,0},{0,0,1,1}},b[4][4]={{3,0,0,0},{0,4,0,0},{0,0,1,0},{0,0,0,2}};
TSMatrix ta,tb,t1;
CreatMat(ta,a[4][4]);
CreatMat(tb,b[4][4]);
return 0;}
显示错误时这样子的
C:\Users\Administrator\Desktop\建文本文档.cpp(66) : error C2664: 'CreatMat' : cannot convert parameter 2 from 'int' to 'int [][4]'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast 展开
typedef int ElemType;
using namespace std;
#define M 4
#define M 4
#define MaxSize 16
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,int A[4][4])
{int j,i;
t.rows=4;t.cols=4;t.nums=0;
for(i=0;i<M;i++)
{for(j=0;j<4;j++)
if(A[i][j]!=0)
{t.data[t.nums].r=i;
t.data[t.nums].c=j;
t.data[t.nums].d=A[i][j];
t.nums++;}}}
int main()
{int a[4][4]={{1,0,3,0},{0,1,0,0},{0,0,1,0},{0,0,1,1}},b[4][4]={{3,0,0,0},{0,4,0,0},{0,0,1,0},{0,0,0,2}};
TSMatrix ta,tb,t1;
CreatMat(ta,a[4][4]);
CreatMat(tb,b[4][4]);
return 0;}
显示错误时这样子的
C:\Users\Administrator\Desktop\建文本文档.cpp(66) : error C2664: 'CreatMat' : cannot convert parameter 2 from 'int' to 'int [][4]'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast 展开
2个回答
展开全部
CreatMat(ta,a[4][4]);
CreatMat(tb,b[4][4]);
这两句修改成
CreatMat(ta,a);
CreatMat(tb,b);
CreatMat(tb,b[4][4]);
这两句修改成
CreatMat(ta,a);
CreatMat(tb,b);

2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询