#include <stdio.h>
unsigned int h=0, i=0, w;
unsigned char Snake_body[2][36] =
{
{0xef,0xdf,0xbf},
{0x10,0x10,0x10}
};
void main()
{
for(i=0; i<36; i++)//判斷陣列中有多少個有效數值,非零數值為有效數值
{
if(Snake_body[0][i] != 0x00)
{
w++;//w為有效數值的個數
}
}
w = w - 2;//為了0號位數值可以被移動并且每一維的最后一個值不移動
//陣列元素位置整體移動
for(h=0; h<2; h++)
{
for(i=w; i>-1; i--)
{
Snake_body[h][i+1] = Snake_body[h][i];//將前一位數值賦給后一位
}
}
w++;
for(h=0; h<2; h++)//輸出所有元素數值
{
for(i=0; i<w; i++)
{
printf("%d,",Snake_body[h][i]);
}
printf("\n");
}
printf("\n");
printf("%d",w);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/135730.html
標籤:新手樂園
上一篇:請教一個時間復雜度的問題
