online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <vector> int MaximumAmount(std::vector<int>& num) { int len = num.size(); int maxAmount = 0, prevAmount = 0; for (int i = 0; i < len; i++) { std::cout <<"maxAmount " << maxAmount << " prevAmount " << prevAmount; int temp = std::max(prevAmount + num[i], maxAmount); prevAmount = maxAmount; maxAmount = temp; std::cout <<" temp " << temp << std::endl; } return maxAmount; } int main() { //std::vector<int> num = {2,7,9,3,1}; std::vector<int> num = {2,1, 1, 2}; int res = MaximumAmount(num); std::cout << res; return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue