Title and requirements Title: Returns the number of the largest subarray in an integer array. Requirements: Into an array of shapes, there are positive numbers in the array and negative numbers. 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. Requires a time complexity of O (n). 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). (As of Thursday March 19 24:00) Two, the pair development process
1. (in Class) we examining together, come up with algorithm implementation, and then we both on the paper to write the specific implementation of the code, each after the completion of each other, to explain each other, looking for imperfect place in the revision.
2. (class) found that the time complexity of the problem has not been resolved, the respective search information, change ideas, coding, mutual interpretation, to improve the sense of inadequacy of our two places.
Third, the source code
Wang Bingwu Donglongyan Date: 2015.3.17
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
int main ()
{
cout<< "---------------------Small program----------------------" to find the maximum value of an array of neutrons <<endl;
cout<<endl;
int a[10];
int i;
Srand ((unsigned) time (NULL));//The random number seed is the current computer.
cout<< "The resulting set of random integers (10 numbers) is as follows:" <<endl;
for (i=0;i<10;i++)
{
A[i] = rand ()%21-10; Randomly generated-integers from 10 to 10
}
for (i=0;i<10;i++)
{
cout<<a[i]<< "";
}
cout<<endl;
int sum=0;
int greatesum=0;
for (i=0;i<10;i++)
{
Sum+=a[i];
if (sum<0)
{
sum=0;
}
if (sum>greatesum)
{
Greatesum=sum;
}
}
if (greatesum==0)
{
for (int i=0;i<10;i++)
{
if (greatesum==0)
{
Greatesum=a[i];
}
Else
if (Greatesum<a[i])
{
Greatesum=a[i];
}
}
}
cout<< "Max sum:" <<GreateSum<<endl;
System ("pause");
return 0;
}
Iv. Results of operation
V. Cooperation and experience
1. Two people cooperation sense of thought came quickly, the problem found in a timely manner, a lot of logical thinking errors. For example, a number of boundary values, I have to slowly test each time, with a partner, he directly said the boundary problem, a little complementary feeling, a lot of high efficiency.
2. At first I drove more, he pilot more points. Thinking has a problem, he driving a little more, I pilot a bit more.
Pair development--classroom practice--c++