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 :
- Let the numbers go in one direction, and the value of each step is increased by 1;
- When the number goes to the end in one direction, it goes in a direction in a clockwise direction.
- 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)