Thoughts on maximum subsequences and problems

xiaoxiao2021-03-06  59

/ * * 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

转载请注明原文地址:https://www.9cbs.com/read-112135.html

New Post(0)