online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <functional> #include <algorithm> #include <iterator> #include <iostream> #include <numeric> #include <vector> int main() { int Idx = 0; int Step = 0; bool Continue = true; std::vector<int>A = {0, 0, 0, 0}; std::vector<std::vector<int>> Matrix = {{3,2},{2,3},{1,0},{4,1},{4,4}}; auto P1 = [&]() -> void { A[0]++; }; auto P2 = [&]() -> void { A[1] += A[3] + 1; }; auto P3 = [&]() -> void { A[2] += ((A[0] + A[1]) % 3 == 0) ? 0 : 7; }; auto P4 = [&]() -> void { A[3] += ((A[0] + A[2]) % 5 == 4) ? 0 : 1; }; auto Fp = [&]() -> void { }; auto D1 = [&]() -> bool { return std::accumulate(A.begin(), A.end(), 0) % 2 == 0; }; auto D2 = [&]() -> bool { return std::accumulate(A.begin(), A.end(), 0) % 7 > 0; }; auto D3 = [&]() -> bool { return std::find_if(A.begin(), A.end(), [](int i){ return i % 2 > 0; }) == A.end(); }; auto D4 = [&]() -> bool { return std::accumulate(A.begin(), A.end(), 0) > 24; }; auto Fd = [&]() -> bool { Continue = false; return false; }; auto Print = [&]() -> void { std::cout << "Step: " << Step << "\tProc: " << (Idx+1) << "\t"; std::copy(A.begin(), A.end(), std::ostream_iterator<int>(std::cout, "\t")); std::cout << std::endl; }; using Process = std::function<void()>; using Decision = std::function<bool()>; std::vector<Process> P = {P1, P2, P3, P4, Fp}; std::vector<Decision> D = {D1, D2, D3, D4, Fd}; // Проход с начала и до конца while(Continue) { Print(); P[Idx](); Idx = Matrix[Idx][(D[Idx]()) ? 0:1]; Step++; } std::cout << "----------------------------------------------------------------\n"; // Эмуляция восстановления в точке перед Proc-4 и продолжение Continue = true; Step = 9; Idx = 3; A = {3, 3 ,14, 1}; while(Continue) { Print(); P[Idx](); Idx = Matrix[Idx][(D[Idx]()) ? 0:1]; Step++; } std::cout << "----------------------------------------------------------------\n"; // использование прекрасного оператора GOTO! label: if (true == false) goto label; 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