gpt4 book ai didi

c# - 随机功能刷新

转载 作者:太空宇宙 更新时间:2023-11-03 10:32:30 25 4
gpt4 key购买 nike

<分区>

Console.WriteLine("How many times would you like to roll?");
string count = Console.ReadLine();
int cnt = Convert.ToInt32(count);

for (int i = 1; i <= cnt; i++)
{
int rol = new int();
Random roll = new Random();
rol = roll.Next(1, 6);
Console.WriteLine("Die {0} landed on {1}.", i, rol);
}

Console.ReadLine();

我试图在 C# 中创建一个掷骰子模拟器,但我遇到了一个问题:随机数在第一次掷骰后永远不会改变。发生了什么事,我该如何解决?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com