Talk C Chestnut Bar (36th: C-language example-spiral matrix)

Source: Internet
Author: User

Ladies and gentlemen, good crossing, the last time we were talking about the test program runtime example, the example we say is: spiral matrix.
Gossip Hugh, words return to the positive. Let's talk C chestnuts together!

Crossing, let's start by talking about the spiral matrix: numbers are arranged in a clockwise direction from small to large until the entire matrix is filled manufactoring. If
We also feel that the more abstract words, you can look at the following figure (the number is gradually increasing in the clockwise direction).

 1  2  3  4  5 16 17 18 19  6 15 24 25 20  7 14 23 22 21  8 13 12 11 10  

the implementation principle of the Helix matrix is as follows :

  1. Let the numbers go in one direction, and the value of each step is increased by 1;
  2. When the number goes to the end in one direction, it goes in a direction in a clockwise direction.
  3. Repeat steps 1 and 2 until there is no free space in the matrix.

Crossing, the text does not write code, the detailed code put in my resources, you can click here to download the use. In the example, I
Used as matrices, traversing matrices can be thought of as traversing arrays.

You crossing, here's an example of a spiral matrix. I want to know what the following example, and listen to tell.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Talk C Chestnut Bar (36th: C-language example-spiral matrix)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.