First pair development

Source: Internet
Author: User

Title: Returns the and of the largest sub-array in an integer array.

Requirements: Enter an array of shapes, with positive numbers in the array and negative values. 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.

Pairs of Members: Chongdong, Yuayan

First, the solution of ideas

First of all, sub-task, Chongdong responsible for program analysis, code programming. Yuayan is responsible for code review and Code re-examination plan.

Second, to discuss the meaning of the topic, to achieve the content, programming ideas

Then, write code, review, and test

Finally, write a blog, the difficulties encountered in the programming process and the understanding of pair development

Second, the experimental code

#include <iostream.h>

int main ()

{

int a[1000];

int Max;

int sum[1000];

int i; int n;

Int J; cout<< "Number of input array members:"; cin>>n;

cout<< "Input 5-tuple array:";

for (i=0;i<5;i++)

{

cin>>a[i];

}

for (i=0;i<5;i++)

{

Sum[i]=a[i];

}

for (i=0;i<4;i++)

{

SUM[5+I]=A[I]+A[I+1];

}

for (i=0;i<3;i++)

{

SUM[9+I]=A[I]+A[I+1]+A[I+2];

}

for (i=0;i<2;i++)

{

SUM[12+I]=A[I]+A[I+1]+A[I+2]+A[I+3];

}

for (i=0;i<1;i++)

{

SUM[14+I]=A[I]+A[I+1]+A[I+2]+A[I+3]+A[I+4];

}

MAX=SUM[0];

for (i=0;i<15;i++)

{

if (Sum[i]>max)

{

Max=sum[i];

J=i;

}

}

cout<< "sub-array and maximum:" << "sum[" <<j<< "]=" <<max<<endl;

return 0;

}

Third, the experimental experience

The first pair of pair training, the benefit is quite deep.

Oneself a person programming time easy to understand the wrong topic, some places may unexpectedly, two people together, this kind of situation basically will not happen, is so-called crowds, mutually make up, complement each other, broaden the train of thought.

For example, at the beginning of the two we had a heated debate on the topic, he understood the determination of the number of groups, I think is arbitrary grouping, and finally through the question of multiple confirmation, should be any grouping, and the sum of each group, and then compare size, output the largest group of sub-array of the sum. Of course, because the foundation is relatively weak, the realization of the function is not particularly good,

This time pair programming, let me believe the 1+1>2 theory!

Iv. Work Photos

First pair development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.