Pair PARTNER:
Guillechang
Blog Name: We're all little monsters.
Links: http://www.cnblogs.com/qwer113/
Design ideas:
1: Create input.txt under the C + + default path
2: Enter the row, column, and corresponding number of the matrix in txt
3: By the column traversal, the Infestation column maximum sub-array, and then find the corresponding results
Program source Code
1//Returns the maximum number of interconnected sub-arrays in a two-dimensional integer group and 2//2016/4/4 3 #include <iostream> 4 using namespace std; 5 #include <fstream> 6 int Zuida (int n, int a[], int *sm, int *mm); 7 8 void Main () 9 {ten int m, n, I, J, SM, MM, t2; int sum, max; char a[100]; int up[100], Dow N[100], t[100]; + int a[100][100], b[100]; cout << "Please enter the file name to read in:"; Cin >> A; Ifstream infile; Infile.open (A, ios::in); if (infile.is_open () = = False) (Cerr << "Open error!" << Endl; exit (1); 2 3} 24//input rows and columns for two-dimensional arrays infile >> m; InFile >> N; (i = 0; i<m; i++) (j = 0; j<n; j + +): {infile>> a[ I][J]; 32} 33} 34//For maximum and for (i = 0; i<m; i++) (j = 0; j<n; j + +) 38 {B[j] = a[i][j]; $ sum = Zuida (n, b, &sm, &mm);Up[i] = SM; Down[i] = mm; T[i] = sum; t2 = t[0]; (i = 0; i + 1<m; i++) (Up[i] <= down[i + 1] && Down[i] >= up[i + 1]) 51 {T2 + = t[i + 1]; (j = up[i]; j<up[i + 1]; j + +) 55 {56 if (a[i + 1][j]>0) t2 + = A[i + 1][j]; Discriminant independent Positive 57} 58 59} 60 61//Output on screen cout << "row of two-dimensional array" << m << Endl; cout << "columns of two-dimensional arrays" << n << Endl; for (i = 0; i<m; i++) (j = 0; j<n; j + +), cout << A[I][J] << ""; cout << Endl; cout << "Max and" << T2 << Endl; Zuida (int n, int a[], int *sm, int *mm) (+) (int) b[100] = {0}; Bayi int i, sum1 = 0, MA x1 = 0; (i = 0; i<n; i++) 83{sum1<0) (sum1 = A[i]; {90} SUM1 = sum1 + a[i]; B[i] = sum1; 94 max1 = b[0]; for (i = 0; i<n; i++) (max1<b[i) 98 {max1 = b[i];100 *mm = i;101}102}103 for (i = *mm; I >= 0; i--) 104 {if (b[i] = = A[i]) 106 { 107 *sm = i;108 break;109}110}111 return max1;112}
Test Cases
1:
2:
Project Plan Summary
Time Recording Log
Defect Logging
The and (pair development) of the maximum number of interconnected sub-arrays