Software Engineering Classroom Training--loop two-dimensional array of pair development

Source: Internet
Author: User

First, title and requirements:

Title: Returns the maximum number of sub-arrays in an integer array and

Request (ADD): ① input A two-dimensional array of shaping, there are positive numbers in the array and negative values; ② two-dimensional arrays end-to-end, like a tape that meets the end-to-end.

Pair of people: Huyabao Gioyan

Second, design ideas:

This topic is actually the combination of two-dimensional array and ring array, in order to solve this problem, the previous two problems can be fused.

First, solve the problem of finding the largest sub-array in two-dimensional array, then follow the method of one-dimensional array, put the first column in the last column, find out the maximal sub-array of the new two-dimensional array, and find out the maximal subarray of each two-dimensional array in turn.

Third, part of the source code:

 1  for(m=0;m<5; m++) 2 { 3      for(cw1=0;cw1<3; cw1++)//Save the first column. 4     { 5flag[cw1]=a[cw1][0]; 6     } 7      for(lie=0;lie<4; lie++)//starting from the second column, the value of each column equals the element behind it 8     { 9          for(hang=0;hang<3; hang++)Ten         { OneA[hang][lie]=a[hang][lie+1]; A         } -     } -      for(cw2=0;cw2<3; cw2++)//the value of the last column is the first column that was just saved the     { -a[cw2][4]=FLAG[CW2]; -     } -}

Four, Experience:

We've only finished part of the experiment, and we've had difficulties with this part of the last two-dimensional array, so we missed this step. Or part of the code. But the mind and the structure are still intact.

Knot pair development advantages also have shortcomings, two people can learn each other's advantages, so as to facilitate the transfer of experience. Can combine two people's thoughts and wisdom. But the program is not written to a single person, but to two of people. So the structure of the code is certainly two people can understand, and the code is the intersection of two human essence that part, is definitely to go to its dross, take the essence. And when I was writing the code, there was an error Huyabao would immediately remind me that I saved a debug-modify-debug time.

Software Engineering Classroom Training--loop two-dimensional array of pair development

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.