|
Dates && Tasks |
Lectures |
Writing Programs |
Read related books |
Find information online |
Total Day |
| Monday |
100 |
|
10 |
30 |
140 |
| Tuesday |
|
120 |
|
30 |
150 |
| Wednesday |
|
30 |
10 |
10 |
50 |
| Thursday |
100 |
20 |
|
|
120 |
| Friday |
|
120 |
|
30 |
150 |
| Saturday |
|
45 |
60 |
10 |
155 |
| Sunday |
|
|
|
|
|
| Weekly totals |
200 |
335 |
80 |
110 |
765 |
Time Recording Log
3/21
| Date |
Start time |
End time |
Interrupt Time |
NET time |
Activities |
Note |
| 3/21 |
14:00 |
15:50 |
10 |
100 |
Lectures |
Software Engineering Classes |
|
21:04 |
21:20 |
6 |
10 |
Read books |
The law of Construction |
|
22:10 |
22:40 |
0 |
30 |
Find information online |
|
| 3/22 |
21:00 |
21:30 |
20 |
120 |
Writing Programs |
Pair development-the sum of sub-arrays |
|
22:15 |
22:45 |
0 |
30 |
Find information online |
|
| 3/23 |
19:25 |
20:00 |
5 |
30 |
Writing Programs |
Pair development-the sum of sub-arrays |
|
22:00 |
22:20 |
10 |
10 |
Read books |
The law of Construction |
|
22:40 |
22:50 |
0 |
10 |
Find information |
|
| 3/24 |
14:00 |
15:50 |
10 |
100 |
Class |
Software Engineering Classes |
|
18:26 |
18:50 |
4 |
20 |
Writing Programs |
Pair development-the sum of sub-arrays |
| 3.2T |
14:00 |
16:20 |
20 |
120 |
Writing Programs |
Pair development-the sum of sub-arrays |
|
11:23 |
12:00 |
7 |
30 |
Find information online |
|
| 3/26 |
7:20 |
9:30 |
30 |
100 |
Read books |
Read the Law of construction |
|
10:00 |
11:00 |
15 |
45 |
Writing Programs |
Pair development-the sum of sub-arrays |
|
9:45 |
9:55 |
0 |
10 |
Find information online |
|
Defect Logging
| Date |
Number |
Type |
Introduction phase |
Exclusion phase |
Repair time |
Note |
| 3/24 |
1 |
20 |
Coding |
Compile |
4 |
The problem of actual participation parameter type correspondence |
| 3/24 |
2 |
20 |
Coding |
Compile |
1 |
Application for dynamic space not released |
| 3.2T |
3 |
20 |
Coding |
Compile |
7 |
When the array length is 0 o'clock, it does not jump out normally |
I.. title and title requirements
1, enter an array of integers, there are positive numbers in the array and negative numbers;
2, a contiguous array of one or more integers constitute a sub-array, each sub-array has a and;
3, the maximum value of all sub-arrays is required and the time complexity is O (n).
Second, design ideas
At first, the enumeration method is used to complete the program, that is, all the sub-arrays are calculated. But since the first one counts, and then the second one counts, the double cycle obviously does not meet the requirements of time complexity. Later, under the guidance of students to understand the dynamic planning to solve such problems meet the requirements. So self-taught the content of dynamic programming, http://baike.baidu.com/link?url=-XGpWNVCf5_ LA6OX8XJXGRCYJP0SMOO88MERMND7T7KEBTHX4CTHRMGKTJOKJLXHSV5BPJBNMPB9NEE_FVTVPQ (Baidu Encyclopedia dynamic Planning).
The following algorithm:
The abstract is a mathematical model that is given a sequence of n integers (which may be negative integers) A1, A2,..., an, to find the maximum number of sub-segments and the sequence shape. When all integers are negative integers, their maximum sub-segments and 0 are defined. According to this definition, the optimal value is:
1) Structure of the optimal solution for the analysis problem
If you remember b[j]=, 1≤i≤n, then the maximum number of sub-segments and is:
by b[j] The definition is easy to know, when B[j-1]>0, B[j]=b[j-1]+a[j], otherwise, b[j]=a[j].
2) establishing a recursive equation
B[J]=MAX{B[J-1]+A[J], A[j]}, 1≤j≤n
Three, code
/*2016.3.22 Weilihua Fengyutong*/#include<iostream>#include<iostream>#include<time.h>using namespacestd;#defineNUM 100000intDtgh_sum (intA[],intN//finding sub-segments and functions by dynamic programming{ intsum =0; int*b = (int*)malloc(n *sizeof(int));//dynamic Array allocation spaceb[0] = a[0]; for(inti =1; I < n; i++) { if(b[i-1] >0) B[i]= B[i-1] +A[i]; ElseB[i]=A[i]; } for(intj =0; J < N; J + +) { if(B[j] >sum) sum=B[j]; } Delete[]b;//Freeing Memory returnsum;}intMain () {intLength=0; while(length==null| | Length = =0)//if the array length is empty or zero, re-enter{cout<<"Please enter the length of the array:"; CIN>>length; } intA[num]; cout<<"input array elements:"<<Endl; for(intI=0; I<= (length-1); i++) {cin>>A[i]; } cout<<"maximum sub-segments and:"; cout<<dtgh_sum (a,length) <<Endl; return 0; }
Four, the operation
Small partners in the same group: http://www.cnblogs.com/a1397240667/p/5294473.html
Pair development-Returns the largest subarray of an array of integers and