0
你好,我正在嘗試創建一個骰子滾動遊戲的頻率表。以下是我正在進行的項目的說明:骰子頻率表c#控制檯
創建一個模擬滾動標準6面模具(編號爲1 - 6)的應用程序。
- 模具應該滾動10,000次。
- 萬卷應該是用戶的輸入;詢問他們多久擲一次骰子
- 擲骰子的值應該根據Random類對象的輸出使用隨機值來確定(請參閱下面的註釋)。
- 程序完成滾動用戶請求的次數(10,000)後,應用程序應該顯示一個表格,顯示每個骰子滾動的次數。
- 程序應該詢問用戶他們是否想模擬另一個擲骰子會話。跟蹤會話的數量。
現在我知道如何使用隨機數類,但我堅持對項目彙總表的一部分,我只是需要的東西,可以幫我上手
這裏是我到目前爲止在項目中,正如你會看到我的彙總表是沒有意義的:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
namespace Dice
{
class Program
{
static void Main(string[] args)
{
Random rndGen = new Random();
Console.WriteLine("welcome to the ralph dice game");
Console.Clear();
Console.WriteLine("how many times do you want to roll");
int rollDice = int.Parse(Console.ReadLine());
for (int i = 0; i < rollDice; i++)
{
int diceRoll = 0;
diceRoll = rndGen.Next(1,7);
string table = " \tfrequency\tpercent";
table +="\n"+ "\t" + i + "\t" + diceRoll;
Console.WriteLine(table);
}//end for
Console.ReadKey();
}
}
}
真的幫了我,但我仍然停留在如何調用從擲骰子是陣列中的這些數字,並把它們放在一個表。 – user2150783 2013-03-11 03:22:51
使用for-loop來讀取數組。 'for(int i = 0; i
luiges90
2013-03-11 05:17:07