这是我的代码:
int counter = 0;
float h = 1.0f;
float phase = 0.0f;
const float hrate = 1.0f / (100.0f * (h * h) + 0.02f);
while (!(phase > 100.0f))
{
phase += hrate;
counter++;
}
std::cout << counter << std::endl;
我需要对其进行微调以输出这些counter
s,对于每个h
(使用我的实际 pc/编译器):
h counter
0.0 3
0.2 403
0.4 1602
0.5 2502
0.6 3602
0.8 6402
1.0 10002
相反,它给了我这个:
h counter
0.0 3
0.2 402 << different
0.4 1602
0.5 2502
0.6 3602
0.8 6403 << different
1.0 10004 << different