/ * * Question Description: * The largest subsequences and problems: give an integer A1, A2, .... AN (possibly negative), * Ask AK to AJ's maximum and value K - J is continuous * Give a linear algorithm (see maxSubsequencesum2.cpp) * / # include
#define Num 8
Void main (void) {// // set the number // int source [NUM];
FOR (int Client = 0; Client
For (Client = 0; Client maxsum) {MaxSum = Clientsum;}} Clientsum = 0;} printf ("/ n% d / n", maxsum);} Time complexity implementation with linearity: / * * Question Description: * Maximum subsequences and problems: give integer A1, A2, ... . N (possibly negative), * Ask AK to AJ's maximum and value K - J is a continuous * maxSubsequencesum2.cpp * / # include
#define Num 8
Void main (void) {// // set the number // int source [NUM];
FOR (int Client = 0; Client
For (Client = 0; Client MaxSum) MaxSum = ClientSum; Else IF (ClientSum <0) // will drop all clientsum = 0; printf ("/ n% d / n", maxsum);} From here you can see and have a lot of time complexity, but the code modification is just a few!
Above code from