码迷,mamicode.com
首页 > 其他好文 > 详细

c实现旋转数列

时间:2015-12-18 06:38:43      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:

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");
  }
}

c实现旋转数列

标签:

原文地址:http://www.cnblogs.com/tang910103/p/5055875.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!