Pairing first experience-finding and Max word groups

Source: Internet
Author: User

trooped Personnel Letter 1201-1 class Caomeina Shing

First, the requirements of the topic and the development of the pair

1. Title: Returns the and of the largest subarray in an integer array.    2, requirements: Enter an array of shaping, 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).    3, pair development requires two people to complete programming tasks.    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). Second, the program design idea the main problem of this program is how to find all the sub-arrays and sum, we use the method is to find all the elements in the array containing all successive sub-arrays, the maximum value of each time to save in another array, and finally find the maximum value in the array, the plot steps are as follows: User input array: (A1,A2,A3,A4) contains all the sub-arrays of the first element {(A1), (A1,A2), (A1,A2,A3), (A1,A2,A3,A4)} contains all the sub-array collections of the second element {(A2), (A2,A3), A2,A3, A4)} contains all the sub-array collections {(A3) of the third element, (A3,A4)} all the sub-array sets {(A4)} containing the fourth element, in turn, to find the maximum value of each array element in the above set and the program source code
1  //Program Developer: Caomeina, Shing2  //Program Development time: 2015/3/183   4#include"stdio.h"5 #defineN 10006 intCompareintArry[],intlength)7 {8     intmax[n],max1;9      for(intj=0; j<length;j++)Ten     { One         intsum=0; Amax1=-12345; -          for(inti=j;i<length;i++) -         { thesum=sum+Arry[i]; -             if(sum>=max1) -max1=sum; -         } +max[j]=max1; -printf"all sub-arrays containing the number of%d in the array and the maximum values are:%d\n", J,max[j]); +     } A     intfmax=max[0]; at      for(intI=0; i<length;i++) -     {     -         if(max[i]>Fmax) -fmax=Max[i]; -     } -printf"The maximum value for the and of all sub-arrays is:%d\n", Fmax); in     return 0; - } to intMainintargcChar*argv[]) + { -     intArry[n]; the     intlength; *printf"Please enter the number of integers to compare:"); $scanf"%d",&length);Panax Notoginsengprintf"Please enter an integer"); -      for(intI=0; i<length;i++) the     { +scanf"%d",&arry[i]); A     } the Compare (arry,length); +     return 0; -}

Iv. Results of operation

Five, experience

In this cooperation process, we fully appreciate the end of the happy. Before we do it ourselves may have a lot of places, two people together to learn from each other, together to discuss. Both improve the quality of the code, but also improve our own level;

We will be more comprehensive than one thinks, and of course it may have a negative effect, such as a person does not do, and then do not do it. However, as long as we treat our small partners correctly, I believe we can all be improved in team work.

A photo of the last pop job

Pairing first experience-finding and Max word groups

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.