Created
November 30, 2012 05:11
-
-
Save anonymous/4173864 to your computer and use it in GitHub Desktop.
Dicerolling!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace DiceRoll | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Random rnd = new Random(); | |
Console.WriteLine("The rolls are as follows:"); | |
int[] amountOfThatSum = new int[11]; | |
for (int i = 1; i <= 36000; i++) | |
{ | |
int roll1 = rnd.Next(1, 7); | |
int roll2 = rnd.Next(1, 7); | |
Console.WriteLine("Roll #{0}: {1} & {2}.{4,5} Sum: {3}", | |
i, roll1, roll2, roll1 + roll2,"",""); //the two blank strings at the end are there simply for formatting purposes. | |
amountOfThatSum[roll1 + roll2 - 2]++; | |
} | |
Console.WriteLine(); | |
for (int i = 2; i <= 12; i++) | |
{ | |
Console.WriteLine("A sum of {0} was rolled {1} times.", | |
i, amountOfThatSum[i - 2]); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment