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: Jiao Yanhu
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 it8 {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:
Software Engineering class Assignment (10)--pair Development (v)