We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
` #include"stdio.h"
#include"stdlib.h"
#define LEN sizeof(Mat) #define num 1000 typedef struct Matrix { int m, n, a; struct Matrix *right, *down; }Mat; Mat *creat() { int i, j; Mat *h, *p, *r1, *r2; h = NULL; r1 = (Mat *)malloc(LEN); r1->right = NULL; r1->down = NULL; scanf("%d", &r1->a); r2 = p = h = r1; for (i = 1;i <= num - 1;i++) { r1 = (Mat *)malloc(LEN); scanf("%d", &r1->a); r1->right = NULL; r1->down = NULL; r2->right = r1; r2 = r1; } for (i = 1;i <= num - 1;i++) { for (j = 1;j <= num;j++) { r1 = (Mat *)malloc(LEN); scanf("%d", &r1->a); r1->right = NULL; r1->down = NULL; if (j == 1) p = p->down = r1; else r2->right = r1; r2 = r1; } } p = h; for (i = 1;i <= num - 1;i++) { r1 = p; r2 = p->down; for (j = 1;j <= num - 1;j++) { r1 = r1->right; r2 = r2->right; r1->down = r2; } p = p->down; } return h; } Mat *creatm() { int i, j; Mat *h, *p, *r1, *r2; h = NULL; r1 = (Mat *)malloc(LEN); r1->a = 0; r1->right = NULL; r1->down = NULL; r2 = p = h = r1; for (i = 1;i <= num - 1;i++) { r1 = (Mat *)malloc(LEN); r1->a = 0; r1->right = NULL; r1->down = NULL; r2->right = r1; r2 = r1; } for (i = 1;i <= num - 1;i++) { for (j = 1;j <= num;j++) { r1 = (Mat *)malloc(LEN); r1->a = 0; r1->right = NULL; r1->down = NULL; if (j == 1) p = p->down = r1; else r2->right = r1; r2 = r1; } } p = h; for (i = 1;i <= num - 1;i++) { r1 = p; r2 = p->down; for (j = 1;j <= num - 1;j++) { r1 = r1->right; r2 = r2->right; r1->down = r2; } p = p->down; } return h; } void print(Mat *h) { Mat *p1, *p2; p1 = p2 = h; do { printf("\n"); do { printf("%d\t", p1->a); p1 = p1->right; } while (p1); p2 = p2->down; p1 = p2; } while (p2); } Mat *mul(Mat *h1, Mat *h2, Mat *h3) { Mat *head; Mat *a1, *a2, *b1, *b2, *c1, c2; int i, j, k, sum; head = h3; a1 = a2 = h1; b1 = b2 = h2; c1 = c2 = h3; for (i = 1;i <= num;i++) { for (j = 1;j <= num;j++) { sum = 0; for (k = 1;k <= num;k++) { sum = sum + a1->ab1->a; a1 = a1->right; b1 = b1->down; } c1->a = sum; c1 = c1->right; b1 = b2 = b2->right; a1 = a2; } c1 = c2 = c2->down; a1 = a2 = a2->down; b1 = b2 = h2; } return head; } int main() { Mat *h1, *h2, *h3; printf("\n矩阵一:"); h1 = creat(); print(h1); printf("\n矩阵二:"); h2 = creat(); print(h2); h3 = creatm(); printf("\n相乘得:"); print(mul(h1, h2, h3)); return 0; } `
The text was updated successfully, but these errors were encountered:
error C2676: 二进制“*”:“Mr”不定义该运算符或到预定义运算符可接收的类型的转换 error C2065: “M”: 未声明的标识符 error: 结构体类型的数据无法直接相乘和赋值
Sorry, something went wrong.
No branches or pull requests
`
#include"stdio.h"
#include"stdlib.h"
#define LEN sizeof(Mat)
#define num 1000
typedef struct Matrix {
int m, n, a;
struct Matrix *right, *down;
}Mat;
Mat *creat()
{
int i, j;
Mat *h, *p, *r1, *r2;
h = NULL;
r1 = (Mat *)malloc(LEN);
r1->right = NULL;
r1->down = NULL;
scanf("%d", &r1->a);
r2 = p = h = r1;
for (i = 1;i <= num - 1;i++)
{
r1 = (Mat *)malloc(LEN);
scanf("%d", &r1->a);
r1->right = NULL;
r1->down = NULL;
r2->right = r1;
r2 = r1;
}
for (i = 1;i <= num - 1;i++)
{
for (j = 1;j <= num;j++)
{
r1 = (Mat *)malloc(LEN);
scanf("%d", &r1->a);
r1->right = NULL;
r1->down = NULL;
if (j == 1)
p = p->down = r1;
else
r2->right = r1;
r2 = r1;
}
}
p = h;
for (i = 1;i <= num - 1;i++)
{
r1 = p;
r2 = p->down;
for (j = 1;j <= num - 1;j++)
{
r1 = r1->right;
r2 = r2->right;
r1->down = r2;
}
p = p->down;
}
return h;
}
Mat *creatm()
{
int i, j;
Mat *h, *p, *r1, *r2;
h = NULL;
r1 = (Mat *)malloc(LEN);
r1->a = 0;
r1->right = NULL;
r1->down = NULL;
r2 = p = h = r1;
for (i = 1;i <= num - 1;i++)
{
r1 = (Mat *)malloc(LEN);
r1->a = 0;
r1->right = NULL;
r1->down = NULL;
r2->right = r1;
r2 = r1;
}
for (i = 1;i <= num - 1;i++)
{
for (j = 1;j <= num;j++)
{
r1 = (Mat *)malloc(LEN);
r1->a = 0;
r1->right = NULL;
r1->down = NULL;
if (j == 1)
p = p->down = r1;
else
r2->right = r1;
r2 = r1;
}
}
p = h;
for (i = 1;i <= num - 1;i++)
{
r1 = p;
r2 = p->down;
for (j = 1;j <= num - 1;j++)
{
r1 = r1->right;
r2 = r2->right;
r1->down = r2;
}
p = p->down;
}
return h;
}
void print(Mat *h)
{
Mat *p1, *p2;
p1 = p2 = h;
do {
printf("\n");
do {
printf("%d\t", p1->a);
p1 = p1->right;
} while (p1);
p2 = p2->down;
p1 = p2;
} while (p2);
}
Mat *mul(Mat *h1, Mat *h2, Mat *h3)
{
Mat *head;
Mat *a1, *a2, *b1, *b2, *c1, c2;
int i, j, k, sum;
head = h3;
a1 = a2 = h1;
b1 = b2 = h2;
c1 = c2 = h3;
for (i = 1;i <= num;i++)
{
for (j = 1;j <= num;j++)
{
sum = 0;
for (k = 1;k <= num;k++)
{
sum = sum + a1->ab1->a;
a1 = a1->right;
b1 = b1->down;
}
c1->a = sum;
c1 = c1->right;
b1 = b2 = b2->right;
a1 = a2;
}
c1 = c2 = c2->down;
a1 = a2 = a2->down;
b1 = b2 = h2;
}
return head;
}
int main()
{
Mat *h1, *h2, *h3;
printf("\n矩阵一:");
h1 = creat();
print(h1);
printf("\n矩阵二:");
h2 = creat();
print(h2);
h3 = creatm();
printf("\n相乘得:");
print(mul(h1, h2, h3));
return 0;
}
`
The text was updated successfully, but these errors were encountered: