In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article is to share with you about how to retrieve the number of characters in SpringBoot. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Problem description
The number of cartridges is taken along the edge of the matrix, and if there are numerous desirable or have been taken in the current direction, turn left 90 degrees. At first, it is located in the upper-left corner of the matrix, with a downward direction.
Input format
The first row of input is two positive integers m, n, not exceeding 200, representing the rows and columns of the matrix. The next m rows are n integers per row, representing the matrix.
Output format
The output has only one row, with a total of m × n m\ times n m × n, which is the result of the return number of the input matrix. Numbers are separated by a space, and there are no extra spaces at the end of the line.
Sample input
3 3
1 2 3
4 5 6
7 8 9
Sample output
1 4 7 8 9 6 3 2 5
Problem-solving ideas
The focus of this question is to find the rules:
(1) in fact, it is easy to see that the order of the output array is a counterclockwise spiral from the outside to the inside.
So we can find the rule: take the output four edges (left, bottom, right, top) as a loop circle, then in the next loop, the starting index and ending index of the four edges are related to the previous one.
(2) there is another problem, that is, how to judge the output. I use a simple method here: add 1 with count count for each output, and stop the output until count is greater than m × n m\ times n m × n.
(3) however, it is important to note that the program may end on any of the four sides, so I added count judgment (count) to the for () loop that outputs each edge.
< m × n m \times n m×n),如果输出完了,立刻停止! 程序清单#includeusing namespace std;int main(){ int m=0,n=0; cin>> m > > ntint a [m] [n]; for (int itimultia [I] [j]; int circle=0,count=0; / / initialization cycles, output count while (count)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.