The solution of three pairs of one-dimensional annular arrays in team project development

Source: Internet
Author: User

The solution of three pairs of one-dimensional annular arrays in team project development

Design idea: By enlarging the length of the array to the original one, the new array is made up of repeating the original array, which ensures that the array is in the form of a ring, in order to compare the largest sub-arrays that they may form sequentially in the order of each number in the array. This ensures that the position of each maximum subarray is always recorded so that it is continuously updated as the program progresses until the sum of the final maximum subarray and the subscript of the largest subarray are obtained.

Source:

//The sum of the largest sub-arrays of a one-dimensional ring array, and requires that the subscripts that comprise the largest subarray be returned//Li min, Apr 12th#include <iostream>#include<time.h>using namespacestd;voidMain () {inta[ -],i,j,m,b,c,maxsum,k=0, t=0, L; cout<<"input Array Length:"<<Endl; CIN>>m; cout<<"Enter the array range, the first number as the upper limit, and the second number as the lower limit:"<<Endl; CIN>>b>>C; //checking the legitimacy of input array lengths    if(m==0|| m<0|| M> -|| m>c-b) {cout<<"the input array length is not valid, please re-enter! "<<Endl; CIN>>m; }    //detect the legitimacy of the input array range    if(b>c| | (b<-2147483648|| b==-2147483648)|| c==2147483647) {cout<<"the number entered is not valid, please re-enter:"<<Endl; CIN>>b>>C; } cout<<"The resulting random number is:"<<Endl;    Srand ((unsigned) time (NULL)); //expands the array length to 2*m     for(i=0; i<m;i++) {A[i]=b+rand ()% (c-b+1); A[m+i]=A[i]; cout<<a[i]<<'\ t'; } maxsum=a[0]; //Compares the sum of the largest sub-arrays consisting of each order bit sequentially, and takes the sum of the largest subarray and the position of the largest sub- array     for(i=0; i<m;i++)    {            intsum=A[i];  for(j=i+1; j<i+m;j++) {sum+=A[j]; if(sum>maxsum) {Maxsum=sum; K=i; T=K; } }} cout<<"The sum of the largest sub-arrays is:"<<maxsum<<Endl; cout<<"successive maximal sub-arrays correspond to the following subscript, in turn:"<<Endl; //The ordinal subscript of the number of the largest sub-arrays in the output ring array, in turn     for(l=k;l<t+1; l++)    {        if(l>m| | l==m) {cout<<l%m<<'\ t'; }        Else{cout<<l<<'\ t'; }    }        }    

Experiment:

Programming Summary: Through this experiment once again enhance our cooperation atmosphere, enhance our sense of teamwork, and let me once again realize the importance of team development, each time the role of exchange so that we can feel the results of different roles to enjoy and mutually complementary, comprehensive views, each play their own advantages, At the same time, timely access to information is also necessary, so that you can improve their professional knowledge and pioneering thinking!

Team player: Li min Liu Zixiang

Work Photo:

The solution of three pairs of one-dimensional annular arrays in team project 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.