daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4.     int subArray[13] = {5,4,-12,7,9,14,-12,19,2,4,-1,-5,14};
  5.     int max,currMax,currTotal = 0;
  6.  
  7.     for (int i = 0; i < 13; i++)
  8.     {
  9.       for (int j = i; j<(13-i); j++){
  10.         currTotal = subArray[j] + currTotal;
  11.         if(currTotal > currMax)
  12.             currMax = currTotal;
  13.       }
  14.  
  15.        currTotal = 0;
  16.        if(currMax > max)
  17.         max = currMax;
  18.  
  19.     }
  20.     cout << max;
  21.     return 0;
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top