online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <iostream> #include <math.h> using namespace std; bool withinLevelBounds(int nReduction, int nLevel) { if (((nReduction * nReduction + nReduction) >> 1) > nLevel) return false; nReduction += 1; if (((nReduction * nReduction + nReduction) >> 1) <= nLevel) return false; return true; } int GetBlockSubsidy(int nHeight) { if (nHeight == 0) { return 400000000; } else if (nHeight <= 5100) { return 1; } else if (nHeight <= 55000) { int l = nHeight - 5000; int nLevel = 0; for (int i = 0; i < l; i+=100) { nLevel++; } return nLevel; } int nStartingSubsidy = 500; int nLevel = (nHeight - 55001) / 32; int nReduction = ((-1 + (int)sqrt((8 * nLevel) + 1)) / 2); while (!(withinLevelBounds(nReduction, nLevel))) { if (((nReduction * nReduction + nReduction) >> 1) > nLevel) { nReduction--; } else { nReduction++; } } int nSubsidyReduction = nReduction; if (nSubsidyReduction >= nStartingSubsidy) return 0; return nStartingSubsidy - nSubsidyReduction; } int main() { int reward = 1; int supply = 0; int i = 0; while(reward > 0) { reward = GetBlockSubsidy(i); supply += reward; i++; } cout << i << endl; cout << supply; 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