Advertisement
capncoolio

diceroller

Apr 16th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1 {
  7.     class Program {
  8.         static void Main(string[] args) {
  9.             int N, D, R;
  10.             double S = 0;
  11.             Random random = new Random();
  12.             int.TryParse(args[0], out N);
  13.             int.TryParse(args[1], out D);
  14.             D++;
  15.             for (int i = 0; i < N; i++) {
  16.                 R = random.Next(1, D);
  17.                 System.Console.Write("{0}\t", R);
  18.                 S += R;
  19.             }
  20.             System.Console.Write("Total: {0}\nAverage: {1}", S, S/N);
  21.             System.Console.ReadKey(true);
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement