Created
June 13, 2012 18:14
-
-
Save anonymous/2925600 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class CubicTest { | |
| static int[] aSequence = {-1,11,-4,13,-5,2} ; | |
| public static void main(String[] args) { | |
| System.out.println( "Total area = " + CubicSeq.maxSubsequenceSum(aSequence)); | |
| System.out.println( /*want to print counter value here*/ ); | |
| System.out.println( /*want to print sequence of integers here*/ ); | |
| } | |
| } | |
| public class CubicSeq | |
| { | |
| public static int maxSubsequenceSum( int [ ] a ) | |
| { | |
| int maxSum = 0; | |
| int seqStart; | |
| int seqEnd; | |
| int Ctr = 0; | |
| for( int i = 0; i < a.length; i++ ) | |
| for( int j = i; j < a.length; j++ ) | |
| { | |
| int thisSum = 0; | |
| Ctr = Ctr++; | |
| for( int k = i; k <= j; k++ ) | |
| thisSum += a[ k ]; | |
| if( thisSum > maxSum ) | |
| { | |
| maxSum = thisSum; | |
| seqStart = i; | |
| seqEnd = j; | |
| } | |
| } | |
| return maxSum; | |
| } | |
| public String toString() { | |
| return //how do I send Ctr value? | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment