我尝试使用 std::random_device
生成随机数,但每次运行程序时它们都是相同的。我使用在线 IDE 尝试了相同的代码,它按预期运行。根据 answer here ,这是Cygwin和MSYS2中的一个错误。
如何升级 MSYS2? 我尝试在终端中运行命令 pacman -Syu
和 pacman -Su
但出现错误:
MSYS ~ $ pacman -Syuu error: mingw32: key
"4A6129F4E4B84AE46ED7F635628F528CF3053E04" is unknown error: key
"4A6129F4E4B84AE46ED7F635628F528CF3053E04" could not be looked up
remotely error: mingw64: key
"4A6129F4E4B84AE46ED7F635628F528CF3053E04" is unknown error: key
"4A6129F4E4B84AE46ED7F635628F528CF3053E04" could not be looked up
remotely error: msys: key "4A6129F4E4B84AE46ED7F635628F528CF3053E04"
is unknown error: key "4A6129F4E4B84AE46ED7F635628F528CF3053E04" could
not be looked up remotely :: Synchronizing package databases...
mingw32 472.5 KiB 305K/s 00:02
[#####################] 100% mingw32.sig 438.0 B
0.00B/s 00:00 [#####################] 100% error: mingw32: key "4A6129F4E4B84AE46ED7F635628F528CF3053E04" is unknown error: key
"4A6129F4E4B84AE46ED7F635628F528CF3053E04" could not be looked up
remotely error: failed to update mingw32 (invalid or corrupted
database (PGP signature)) mingw64 475.0 KiB 346K/s
00:01 [#####################] 100% mingw64.sig 438.0 B
0.00B/s 00:00 [#####################] 100% error: mingw64: key "4A6129F4E4B84AE46ED7F635628F528CF3053E04" is unknown error: key
"4A6129F4E4B84AE46ED7F635628F528CF3053E04" could not be looked up
remotely error: failed to update mingw64 (invalid or corrupted
database (PGP signature)) msys 189.8 KiB 164K/s
00:01 [#####################] 100% msys.sig 438.0 B
0.00B/s 00:00 [#####################] 100% error: msys: key "4A6129F4E4B84AE46ED7F635628F528CF3053E04" is unknown error: key
"4A6129F4E4B84AE46ED7F635628F528CF3053E04" could not be looked up
remotely error: failed to update msys (invalid or corrupted database
(PGP signature)) error: failed to synchronize all databases
是否有任何替代方案或解决方法可以在 Windows 上生成随机数?
最佳答案
我通过引用this news page on MSYS2让它工作。我必须先运行 pacman -Sydd pacman
,然后其余步骤才能起作用。
关于c++ - 为什么随机数和MSYS2都一样?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63201980/