A . Development Ideas
First design a 3 Line 4 The matrix of the column.
then the A each column of the row is added as the first 4 line.
will be at each column of the row is added as the first 5 line.
will be 123 each column of the row acts as the sixth row.
then list the sub-arrays of each row to find the maximum value.
Finally, the maximum size of each row is compared, and the final result is obtained.
Two . Development Code
#include <iostream.h>
int main ()
{
int x,y,n,m;
int s[10][20];
int a[10][20];
int sum[10][20];
cout<< "Please enter3Line4matrix of columns:"<<endl;
int a[][4]={10,-6,-1,3,-7,20,3,7,-2,4,2,-19};
for (x=0;x<3;x++)
{
for (y=0;y<4;y++)
{
cout<<a[x][y]<< "\ t";
}
cout<<endl;
}
//---------------------------The above is the input of the array
for (y=0;y<4;y++)
{
for (x=0;x<3;x++)
{
S[x][y]=a[x][y];
}
}
for (x=0;x<2;x++)
{
for (y=0;y<4;y++)
{
S[x+3][y]=a[x][y]+a[x+1][y];
}
}
for (y=0;y<4;y++)
{
S[5][y]=a[0][y]+a[1][y]+a[2][y];
}
//---------------------------------------------------
for (x=0;x<6;x++)
{
for (y=0;y<4;y++)
{
Sum[x][y]=s[x][y];
}
for (y=0;y<3;y++)
{
SUM[X][Y+4]=S[X][Y]+S[X][Y+1];
}
for (y=0;y<2;y++)
{
SUM[X][Y+7]=S[X][Y]+S[X][Y+1]+S[X][Y+2];
}
for (y=0;y<1;y++)
{
SUM[X][Y+9]=S[X][Y]+S[X][Y+1]+S[X][Y+2]+S[X][Y+3];
}
}
//-------------------------------------------------------------------------
/*
for (x=0;x<6;x++)
{
for (y=0;y<10;y++)
{
if (sum[x][y]==30)
cout<<x<<endl<<y<<endl;
}
}
*/
//-----------------------------
int max=sum[0][0];
for (x=0;x<6;x++)
{
for (y=0;y<10;y++)
{
if (Sum[x][y]>max)
{
Max=sum[x][y];
N=x;
M=y;
}
}
}
//--------------------------------------To find the maximum number
if (n<3)
{
cout<< "Array start line:"<<n+1<<endl<<"Array End Line:"<<n+1<<endl;
}
Else
{
n=n%3;
Switch (0)
{
Case 0:cout<< "Array start line:"<<n<<endl<<"Array End Line:"<<n+1<<endl;break;
Case 1:cout<< "Array start line:"<<n<<endl<<"Array End Line:"<<n+1<<endl;break;
Case 2:cout<< "Array start line:"<<n<<endl<<"Array End Line:"<<n+2<<endl;break;
}
}
//-----------------------------------------------------------------------------to begin a row of a sub-array
if (m<4)
{
cout<< "Array Start column:"<<m<<endl<<"Array Start column:"<<m<<endl;
}
else if (m>3&&m<8)
{
{
m=m%4;
Switch (m)
{
Case 0:cout<< "Array Start column:1 "<<endl<< "array End column:2 "<<endl;break;
Case 1:cout<< "Array Start column:2 "<<endl<< "array End column:3 "<<endl;break;
Case 2:cout<< "Array Start column:3 "<<endl<< "array End column:4 "<<endl;break;
Case 3:cout<< "Array Start column:1 "<<endl<< "array End column:3 "<<endl;break;
}
}
}
else if (m>7)
{
m=m%8;
Switch (m)
{
Case 0:cout<< "the start line of the array:2 "<<endl<< "End column of the array:4 "<<endl;break;
Case 1:cout<< "the start line of the array:1 "<<endl<< "End column of the array:4 "<<endl;break;
}
}
cout<< "the largest sub-array and is:max= "<<max<<endl;
return 0;
}
Three.Development Results
Iv. Summary of the pair
The idea of discovering this program is very simple to think of, but in the process of writing Cheng the most troublesome is to calculate the number of cycles from the first several cycles, but another partner, can easily pass the problem.
And in the final stage of development, the partners gave me a lot of suggestions such as the output of the maximum sub-matrix, although it is more troublesome for me to make changes to the program, but to make the program more perfect and practical. In the process of pairing need to understand each other, but also to have the ability to communicate with people, in the process of writing almost because of a little bit of trouble, I think we still need to improve.
Pair development Two--the largest of the matrix sub-matrices