zoukankan      html  css  js  c++  java
  • 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(" ");
      }
    }

  • 相关阅读:
    进制
    流程控制
    运算符
    格式化输出
    数据结构-树的遍历
    A1004 Counting Leaves (30分)
    A1106 Lowest Price in Supply Chain (25分)
    A1094 The Largest Generation (25分)
    A1090 Highest Price in Supply Chain (25分)
    A1079 Total Sales of Supply Chain (25分)
  • 原文地址:https://www.cnblogs.com/tang910103/p/5055875.html
Copyright © 2011-2022 走看看