online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Obtener las sumas acumuladas del arreglo nums tal que sumasAcumuladas[i] = suma(nums[0] .. nums[i]). Ejemplo: Entrada: [1,2,3,4] Salida: [1,3,6,10] (se calcula como: [1, 1+2, 1+2+3, 1+2+3+4]) *******************************************************************************/ #include <iostream> #include <vector> using namespace std; vector<int> sumasAcumuladas(vector<int> &nums) { vector<int> resultado = {nums[0]}; for (int i = 1; i < nums.size(); i++) { resultado.push_back(resultado.back() + nums[i]); } return resultado; } int main() { vector<int> original = {2, 4, 6, 8, 10, 12}; for (int n : sumasAcumuladas(original)) { cout << n << " "; } cout << endl; 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