# Week five Classroom Test

Source: Internet
Author: User

Design ideas:

1, by invoking the input function for array input;

2, using the classroom Teacher's dynamic planning of the array of sub-arrays to find the maximum operation;

* 3, add a max0 to the maximum value of the storage, to avoid the maximum occurrence of the middle of the array caused by the missing problem;

Problems that arise:

Long time no eclipse, a lot of basic operations also need to review to be able;

Digital input code through the Internet query to knock good;

Possible solutions:

Other methods that are currently not expected to be within the allowable range of time complexity;

Source:

`Package Max;import java.util.*; Public classArray_max { Public Static intCin (inti) {Scannerinch=NewScanner (System.inch); System. out. println ("Please enter section"+ (i+1)+"number"); intb=inch. Nextint (); returnb; }     Public Static intGet (intLen[],intnum) {        intmax = len[0]; intmax0=0;  for(intI=1; i<num;i++){            if(len[i]>0) {Max=max+Len[i]; }            Else{                if(max>max0) {max0=Max; } Max=0; }        }        returnmax0; }     Public Static voidMain (String args[]) {Scannerinch=NewScanner (System.inch); System. out. println ("Please enter the number of array numbers:"); intnum=inch. Nextint (); intlen[]=New int[num];  for(intI=0; i<num;i++) {Len[i]=Cin (i); }        intmax=Get (Len,num); System. out. Print ("the maximum number of sub-arrays and is:"+max); }}`

Results:

Summary: In fact, the code is very simple, the key is the thought is very difficult to think, if there is no class teacher to mention, estimated that only thinking will cost a lot of time!

Week five Classroom Test

Related Keywords:

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.