online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
<!DOCTYPE html> <html> <body> <p id="white"></p> <p id="red"></p> <p id="d6"></p> <script> var white = [0, 0, 0, 0, 1, 2], //White Space Crusade die red = [0, 0, 0, 3, 1, 2], //Red Space Crusade die d6 = [1, 2, 3, 4, 5, 6], //Normal D6 d10 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ], //Normal D10 result; document.getElementById("red").innerHTML = "Calculating"; document.getElementById("white").innerHTML = "Calculating"; document.getElementById("d6").innerHTML = "Calculating"; result = trials(white, 10000, rerollOne); document.getElementById("white").innerHTML = "The rolls were <br>" + displayResult(result, 100) + " "; result = trials(red, 10000, rerollOne); document.getElementById("red").innerHTML = "The rolls were <br>" + displayResult(result, 100) + " "; result = trials(d6, 10000, rollTwo); document.getElementById("d6").innerHTML = "The rolls were <br>" + displayResult(result, 100) + " "; function displayResult(anArray, divide) {//result array, divisor for output to make it look like a percentage var i, limit, str = ""; limit = anArray.length; for (i = 0; i < limit; i++) { str += i; str += ": "; str += anArray[i] / divide; str += " %<br>"; } return str; } function trials(diceArray, times, funct) {//die array, number of iterations, function to use var i, roll, result = []; for (i = 0; i < times; i++) { roll = funct(diceArray); while (result.length < roll + 1) {//make result array bigger if needs be result.push(0); } result[roll] = result[roll] + 1; } return result; } function rollDie(colorDie) {//returns a random die roll result return colorDie[randIndex(colorDie.length)] } function randIndex(num) { return Math.floor((Math.random() * num)); } function rollTwo(colorDie) {//simple total var die1, die2; die1 = rollDie(colorDie); die2 = rollDie(colorDie); return die1 + die2; } function rerollOne(colorDie) {// if one result is zero, reroll it var die1, die2, reroll; die1 = rollDie(colorDie); die2 = rollDie(colorDie); reroll = rollDie(colorDie); if (die1 === 0) { die1 = reroll; //reroll first die if zero } else { if (die2 === 0) { die2 = reroll; //otherwise reroll second die if zero } } return die1 + die2; //total of 2 dice } </script> </body> </html>

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