Title: Expands on an existing array to find the sum of the largest sub-arrays of the end-to-end connections:
Requirements: Enter a one-dimensional shape array with positive and negative numbers in the array.
One or more consecutive integers in an array make up a sub-array, each of which has a and.
The maximum value for the and of all sub-arrays.
Pair programming Requirements: The pair completes the programming task. One person is mainly responsible for program analysis, code programming.
One person is responsible for code review and Code test plan.
Publish a blog post about the process, experience, and how to resolve conflicts between two people (attach a work photo of the development).
Pair development process:
This time the programming is based on the last thought of the array, I and my partner Angel LR Demon began a serious discussion, and then combined with class discussion, how can be in a one-dimensional array on the basis of the original, coupled with the end-to-end condition, while reducing the complexity of time, The approximate idea of this method is: Iterate through the array of each number of the first number into the last number, the specific algorithm a[i-1]=a[i], this becomes a new one-dimensional array, output the maximum number of sub-arrays per array, and then compare each output and, find the largest:
Source:
#include <iostream.h> int maxsum (int* A, int n)//defines a method {int sum=0 that is the largest subarray of a one-dimensional array; int b=0; for (int i=0; i<n; i++) {if (b<0) b=a[i]; else B+=a[i]; if (sum<b) sum=b; } return sum; } int main () {int n,temp,b; int sum=0; int i; int a1,a2; cout<< "Please enter the number of elements in the array:" <<endl; cin>>n; cout<< "Please enter the elements of the array:" <<endl; int *a=new Int[n]; for (i=0;i<n;i++) {cin>>a[i];} cout<< "The maximum number of sub-arrays in this end-to-end array is possible with the following:" <<endl; cout<< "1th arrangement:" <<endl; for (i=0;i<n;i++) {cout<<a[i]<< "";} cout<< "Maximum sub-array and as:" <<maxsum (a,n) <<endl; A1=maxsum (A,n); for (b=1;b<n;b++) {temp=a[0]; for (i=1;i<=n;i++) {a[i-1]=a[i]; } a[n-1]=temp; cout<< "<<b+1<<" type of Arrangement: "<<endl; for (i=0;i<n;i++) {cout<<a[i]<< "";} cout<< "Maximum sub-array and as:" <<maxsum (a,n) <<endl; if (Maxsum (a,n) >=sum) {sum=maxsum (a,n);} } a2=sum; cout<<endl; if (A1>=A2) {cout<< "In the sum, the largest subarray and is:" <<A1<<ENDL;} Else {cout<< "On top, the largest sub-array and is:" <<A2<<ENDL;} return 0; }
:
Feelings:
Cooperation is called cooperation because it is a matter of two or more people. In an array of exercises today, my teammates and I discussed this topic so that we could have a clearer understanding of the problem and let the programming be handy.
Cooperation:
An array of the largest subarray and