Unsigned int h=0, I=0, w.
Unsigned char Snake_body [2] [36]=
{
XBF XDF xef {0, 0, 0},
{0 x10, 0 x10, 0 x10}
};
Void main ()
{
for(i=0; I<36. I++)//how many effective numerical value in an array, a non-zero value for effective numerical
{
If (Snake_body [0] [I]!=0 x00)
{
W++;//w for the number of effective numerical
}
}
W=w - 2;//to 0 bit values can be mobile and each dimension of the last value does not move
//array element position overall mobile
For (h=0; h<2; H++)
{
For (I=w; I> - 1; I -)
{
Snake_body [h] [I + 1)=Snake_body [h] [I];//will be before after a value is assigned to a
}
}
W++;
For (h=0; h<2; H++)//output all element numerical
{
for(i=0; I
Printf (" % d ", Snake_body [h] [I]);
}
printf("\n");
}
printf("\n");
Printf (" % d ", w);
}
CodePudding user response:
Didn't understand how do you want to move? Do you want to move non-zero elements or every item in addition to the last item in the future mobile? Didn't understand statistical w you want to do? W is the number 0, not the last of a subscript, so you for I=w, I, really want to move? W - 2 and want to do? It is better to direct you describe what is the result you want,