# 23: Two-dimensional array loopback traversal

Source: Internet
Author: User

23: Two-dimensional array loopback traversal
• View
• Submit
• Statistics
• Questions
Total time limit:
1000ms
Memory Limit:
65536kB
Describe

Given an integer array of row row col columns, requires starting from the array[0][0] element, and pressing the back shape to traverse the entire array in a clockwise order from outward. ：

Input
The first line of input has two integers, row and col, in turn.
The remaining row rows, each containing a col integer, form a two-dimensional array of integers.
(Note: The input row and col guarantees 0 < row < 0 < col < 100)
Output
Each integer is output in the traversal order. Each integer occupies one row.
Sample input
`4 41 2 3 412 13 14 511 16 15 610 9 8 7`
Sample output
`12345678910111213141516`
Source
2009 years of medical practice at Peking University
• View
• Submit
• Statistics
• Questions
`1#include <iostream>2#include <cstdio>3#include <cstdio>4#include <cstring>5 using namespacestd;6 inta[ -][ -];7 intb[ -][ -];8 intMain ()9 {Ten     intm,n,i,j; OneCin>>m>>N; A      for(i=1; i<=m;i++) -      { -           for(j=1; j<=n;j++) the           { -Cin>>A[i][j]; -           } -      } +       for(intq=1; q<=n/2+1; q++) -      { +       for(i=q;i<=m-q+1; i++) A         {   at             for(j=q;j<=n-q+1; j + +) -             { -               if(i==q| | j==n-q+1) -                { -cout<<a[i][j]<<Endl; -b[i][j]=1; in               } -            } to          } +          for(i=m-q+1; i>=q;i--) -          { the               for(j=n-q+1; j>=q;j--) *               { \$                   if((i==m-q+1|| J==Q) &&b[i][j]==0)Panax Notoginseng                    { -cout<<a[i][j]<<Endl; the                 } +             } A          } the      } +}`

23: Two-dimensional array loopback traversal

Related Keywords:

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.