TI中文支持网
TI专业的中文技术问题搜集分享网站

CCS中定义了一个数组报错了,找不到问题

int Kp1[13][13]={{6;6;6;5;4;4;4;3;2;2;2;1;0},
     {6;6;6;5;4;3;3;3;2;1;0;-1;-1},
     {6;6;6;5;4;3;2;2;2;1;0;-1;-2},
     {5;5;5;5;4;3;2;1;1;0;-1;-1;-2},
     {4;4;4;4;4;3;2;1;0;-1;-2;-2;-2},
     {4;4;4;3;3;2;1;0;-1;-2;-3;-3;-3},
     {4;4;4;3;2;1;0;-1;-2;-3;-4;-4;-4},
     {3;3;3;2;1;0;-1;-1;-2;-3;-4;-4;-4},
     {2;2;2;1;0;-1;-2;-2;-2;-3;-4;-4;-4},
     {2;1;1;0;-1;-2;-3;-3;-3;-3;-4;-5;-5},
     {2;1;0;-1;-2;-3;-4;-4;-4;-4;-4;-5;-6},
     {1;1;0;-2;-3;-3;-4;-4;-4;-5;-5;-5;-6},
     {0;0;0;-2;-4;-4;-4;-4;-4;-5;-6;-6;-6}
       };

如题,这是我定义的13×13数组却报错了,清大佬们帮我看看哪里有问题?报错语句如下(line 50就是第一行)

"pid_reg3.c", line 50: error: declaration may not appear after executable statement in block
"pid_reg3.c", line 50: error: expected a "}"
"pid_reg3.c", line 50: error: expected a "}"
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: error: expected a ";"
"pid_reg3.c", line 50: warning: variable "Kp1" was declared but never referenced
"pid_reg3.c", line 50: error: expected a declaration

mangui zhang:int Kp1[13][13]={{6;6;6;5;4;4;4;3;2;2;2;1;0},应该是={{6,6,6,5,4,4,4,3,2,2,2,1,0},分别赋值不能用封号

int Kp1[13][13]={{6;6;6;5;4;4;4;3;2;2;2;1;0},
     {6;6;6;5;4;3;3;3;2;1;0;-1;-1},
     {6;6;6;5;4;3;2;2;2;1;0;-1;-2},
     {5;5;5;5;4;3;2;1;1;0;-1;-1;-2},
     {4;4;4;4;4;3;2;1;0;-1;-2;-2;-2},
     {4;4;4;3;3;2;1;0;-1;-2;-3;-3;-3},
     {4;4;4;3;2;1;0;-1;-2;-3;-4;-4;-4},
     {3;3;3;2;1;0;-1;-1;-2;-3;-4;-4;-4},
     {2;2;2;1;0;-1;-2;-2;-2;-3;-4;-4;-4},
     {2;1;1;0;-1;-2;-3;-3;-3;-3;-4;-5;-5},
     {2;1;0;-1;-2;-3;-4;-4;-4;-4;-4;-5;-6},
     {1;1;0;-2;-3;-3;-4;-4;-4;-5;-5;-5;-6},
     {0;0;0;-2;-4;-4;-4;-4;-4;-5;-6;-6;-6}
       };

如题,这是我定义的13×13数组却报错了,清大佬们帮我看看哪里有问题?报错语句如下(line 50就是第一行)

"pid_reg3.c", line 50: error: declaration may not appear after executable statement in block
"pid_reg3.c", line 50: error: expected a "}"
"pid_reg3.c", line 50: error: expected a "}"
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: error: expected a ";"
"pid_reg3.c", line 50: warning: variable "Kp1" was declared but never referenced
"pid_reg3.c", line 50: error: expected a declaration

user6007383:

回复 mangui zhang:

太谢谢了

int Kp1[13][13]={{6;6;6;5;4;4;4;3;2;2;2;1;0},
     {6;6;6;5;4;3;3;3;2;1;0;-1;-1},
     {6;6;6;5;4;3;2;2;2;1;0;-1;-2},
     {5;5;5;5;4;3;2;1;1;0;-1;-1;-2},
     {4;4;4;4;4;3;2;1;0;-1;-2;-2;-2},
     {4;4;4;3;3;2;1;0;-1;-2;-3;-3;-3},
     {4;4;4;3;2;1;0;-1;-2;-3;-4;-4;-4},
     {3;3;3;2;1;0;-1;-1;-2;-3;-4;-4;-4},
     {2;2;2;1;0;-1;-2;-2;-2;-3;-4;-4;-4},
     {2;1;1;0;-1;-2;-3;-3;-3;-3;-4;-5;-5},
     {2;1;0;-1;-2;-3;-4;-4;-4;-4;-4;-5;-6},
     {1;1;0;-2;-3;-3;-4;-4;-4;-5;-5;-5;-6},
     {0;0;0;-2;-4;-4;-4;-4;-4;-5;-6;-6;-6}
       };

如题,这是我定义的13×13数组却报错了,清大佬们帮我看看哪里有问题?报错语句如下(line 50就是第一行)

"pid_reg3.c", line 50: error: declaration may not appear after executable statement in block
"pid_reg3.c", line 50: error: expected a "}"
"pid_reg3.c", line 50: error: expected a "}"
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: warning: expression has no effect
"pid_reg3.c", line 50: error: expected a ";"
"pid_reg3.c", line 50: warning: variable "Kp1" was declared but never referenced
"pid_reg3.c", line 50: error: expected a declaration

Susan Yang:谢谢楼上的回答

网上也有很多教程讲解,您可以了解一下

wiki.jikexueyuan.com/…/arrays.html

赞(0)
未经允许不得转载:TI中文支持网 » CCS中定义了一个数组报错了,找不到问题
分享到: 更多 (0)