马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 孤世星辰 于 2020-3-28 20:25 编辑 test2.c: In function ‘main’:
test2.c:5: error: variable-sized object may not be initialized
test2.c:6: warning: excess elements in array initializer
test2.c:6: warning: (near initialization for ‘a[0]’)
test2.c:6: warning: excess elements in array initializer
test2.c:6: warning: (near initialization for ‘a[0]’)
test2.c:6: warning: excess elements in array initializer
test2.c:6: warning: (near initialization for ‘a[0]’)
test2.c:6: warning: excess elements in array initializer
test2.c:6: warning: (near initialization for ‘a’)
test2.c:7: warning: excess elements in array initializer
test2.c:7: warning: (near initialization for ‘a[0]’)
test2.c:7: warning: excess elements in array initializer
test2.c:7: warning: (near initialization for ‘a[0]’)
test2.c:7: warning: excess elements in array initializer
test2.c:7: warning: (near initialization for ‘a[0]’)
test2.c:7: warning: excess elements in array initializer
test2.c:7: warning: (near initialization for ‘a’)
test2.c:8: error: variable-sized object may not be initialized
test2.c:9: warning: excess elements in array initializer
test2.c:9: warning: (near initialization for ‘b[0]’)
test2.c:9: warning: excess elements in array initializer
test2.c:9: warning: (near initialization for ‘b[0]’)
test2.c:9: warning: excess elements in array initializer
test2.c:9: warning: (near initialization for ‘b’)
test2.c:10: warning: excess elements in array initializer
test2.c:10: warning: (near initialization for ‘b[0]’)
test2.c:10: warning: excess elements in array initializer
test2.c:10: warning: (near initialization for ‘b[0]’)
test2.c:10: warning: excess elements in array initializer
test2.c:10: warning: (near initialization for ‘b’)
test2.c:11: warning: excess elements in array initializer
test2.c:11: warning: (near initialization for ‘b[0]’)
test2.c:11: warning: excess elements in array initializer
test2.c:11: warning: (near initialization for ‘b[0]’)
test2.c:11: warning: excess elements in array initializer
test2.c:11: warning: (near initialization for ‘b’)
test2.c:12: error: variable-sized object may not be initialized
test2.c:12: warning: excess elements in array initializer
test2.c:12: warning: (near initialization for ‘c[0]’)
test2.c:12: warning: excess elements in array initializer
test2.c:12: warning: (near initialization for ‘c’)
test2.c:14: error: expected ‘;’ before ‘)’ token
test2.c:16: error: expected ‘;’ before ‘)’ token
1 #include<stdio.h>
2 int main()
3 {
4 int m=2,p=3,n=2;
5 int a[m][p]={
6 {1,2,3,},
7 {4,5,6,}};
8 int b[p][n]={
9 {1,4},
10 {2,5},
11 {3,6}};
12 int c[n][m]={0};
13 int i,j,k,row;
14 for(i=0,i<m;i++)
15 {
16 for(j=0,j<n;j++)
17 {
18 for(k=0;k<p;k++)
19 {
20 c[i][j]+=a[i][k]*b[k][i];
21 }
22 }
23 }
24 row=m>p?m:p;
25 for(i=0;i<row;i++)
26 {
27 //打印a
28 printf("| ");
29 for(j=0;j<p;j++)
30 {
31 if(i<m)
32 {
33 printf("\b%d ",a[i][j]);
34 printf("|");
35 }
36 else
37 {
38 printf("\b\b\b ");
39 }
40 }
41 //打印*
42 if(i==row/2)
43 {
44 printf(" * ");
45 }
46 else
47 {
48 printf(" ");
49 }
50 printf("| ");
51 //打印b
52 for(j=0;j<n;j++)
53 {
54 if(i<p)
55 {
56 printf("\b%d ",b[i][j]);
57 }
58 else
59 {
60 printf("\b\b\b ");
61 }
62 }
63 //打印=
64 if(i==row/2)
65 {
66 printf(" = ");
67 }
68 else
69 {
70 printf(" ");
71 }
72 //打印c
73 for(j=0;j<n;j++)
74 {
75 if(i<m)
76 {
77 printf("\b%d ",c[i][j]);
78 }
79 else
80 {
81 printf("\b\b\b ");
82 }
83 }
84 printf("\n");
85 }
86 }
这个是要求,要打印成这个样子
我没定义字符串数组啊,哪里错了??
|