Software Engineering Personal Job 04 (finding the largest array of arrays)

Source: Internet
Author: User
Tags net time

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

Requirements:
Enter a one-dimensional shape array with positive and negative numbers in the array.
One-dimensional arrays end-to-end, like one end-to-end tape.
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.

Programming Ideas: A function used in the program to find the largest array of arrays and functions, where the original array of the first n-1 items can be added to the back of the array, to form a new array, so that the end-to-end array of the maximum number of sub-arrays and.

Source:


public class Zishuzu {

/**
* @param args
*/

public static int max (int array[])
{
int max=0;
int sum=0;
int Len;
Len=array.length;
for (int i=0;i<len;i++)
{
Sum+=array[i];
if (Sum>max)
{
Max=sum;
}
if (sum<0)
{
sum=0;
}
}
return Max;

}
public static void Main (string[] args) {
TODO auto-generated Method Stub
int a[]={1,2,-3,5,7,-8};
System.out.print ("Test array is:");
for (int i=0;i<a.length;i++)
{
System.out.print (a[i]+ ",");
}
System.out.println ("");
System.out.println ("The value of the maximum subarray of the array is:" +max (a));
int b[]={1,2,-3,5,7,-8,1,2,-3,5,7};
System.out.print ("The array is equivalent to:" After connecting the array to the end);
for (int k=0;k<b.length;k++)
{
System.out.print (b[k]+ ",");
}
System.out.println ("");

System.out.println ("The value of the maximum subarray of the array is:" +max (b));

}

}



Test results:

Weekly Activity Summary table:

Date/ Task

Lectures

Read the textbook

Study under the class

Total Day

Sunday on 3.26

Monday

120m

30m

30m

150m

Tuesday

40m

40m

Wednesday

50m

50m

Thursday

120m

40m

20m

180m

Friday

40m

40m

Saturday

40m

40m

Weekly totals

240m

80B

2100m

540m

Time log:

date

start time

end time

Interrupt time

net time

active

remarks

c

u

3.6

14:00

16:00

10m

110m

class, programming

Software engineering lesson

 

3.7

19:00

21:00

20m

100m

reading, programming

write software engineering jobs

 

 

3.8

19:00

21:00

15m

105m

reading, programming

learn javaweb

 

 

3.9

16:00

18:00

10m

110m

class

javaweb class

 

3.10

18:00

20:00

30m

90m

Idea, write Java

Write the four Operation program 3

Software Engineering Personal Job 04 (finding the largest array of arrays)

Related Article

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.