Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int subArray[13] = {5,4,-12,7,9,14,-12,19,2,4,-1,-5,14};
- int max,currMax,currTotal = 0;
- for (int i = 0; i < 13; i++)
- {
- for (int j = i; j<(13-i); j++){
- currTotal = subArray[j] + currTotal;
- if(currTotal > currMax)
- currMax = currTotal;
- }
- currTotal = 0;
- if(currMax > max)
- max = currMax;
- }
- cout << max;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement