Skip to content

Instantly share code, notes, and snippets.

@mstefarov
Forked from anonymous/diceroll.cs
Created November 30, 2012 06:14
Show Gist options
  • Save mstefarov/4174077 to your computer and use it in GitHub Desktop.
Save mstefarov/4174077 to your computer and use it in GitHub Desktop.
Dicerolling!
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}. Sum: {3}",
i, roll1, roll2, roll1+roll2);
amountOfThatSum[ roll1+roll2 ]++;
}
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