【发布时间】:2020-10-26 14:08:11
【问题描述】:
我最近尝试在我的Windows 10 桌面中通过VSCode 扩展安装QDK,即使在我能够通过dotnet 在终端上运行命令。该代码是本教程的创建新项目部分中描述的示例项目代码。我也没有.NET SDK,所以我安装了它,但它似乎工作正常。在计算机中,我遇到了所有代码的问题,都与找不到命名空间有关。
namespace QuantumRNG {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Measurement;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Convert;
operation GenerateRandomBit() : Result {
using (q = Qubit()) {
H(q);
return MResetZ(q);
}
}
operation SampleRandomNumberInRange(max : Int) : Int {
mutable output = 0;
repeat {
mutable bits = new Result[0];
for (idxBit in 1..BitSizeI(max)) {
set bits += [GenerateRandomBit()];
}
set output = ResultArrayAsInt(bits);
} until (output <= max);
return output;
}
@EntryPoint()
operation SampleRandomNumber() : Int {
let max = 50;
Message($"Sampling a random number between 0 and {max}: ");
return SampleRandomNumberInRange(max);
}
}
【问题讨论】:
-
您在输出控制台中看到任何错误消息吗?
标签: visual-studio-code q#