c实现旋转数列

void main (void)
{
  int line = 5;
  int x = 0,y = 0,ringNumber = 0,number = 0;
  int A[line][line] = {0};
  while (number <= line * line)
  {
    while (x < line - ringNumber)
    {
      number++;
      A[x][y] = number;
      x++;
    }
    y++;
    x--;
    while (y < line - ringNumber)
    {
      number++;
      A[x][y] = number;
      y++;
    }
    x--;
    y--;
    while (x >= ringNumber)
    {
      number++;
      A[x][y] = number;
    x--;
    }
    y--;
    x++;
    while (y > ringNumber)
    {
      number++;
      A[x][y] = number;
      y--;
    }
    x++;
    y++;
    ringNumber++;
  }
  for (int x = 0; x < line ;x++)
  {
    for(int y = 0 ;y < line; y++)   

    {

      printf("%d ",A[x][y]);

    }
    printf("\n");
  }
}

posted on 2015-12-18 01:09  tang杰  阅读(281)  评论(0编辑  收藏  举报

导航