我试图for使用2个嵌套循环打印结果std::cout.但是,结果不会立即打印到控制台,但会有延迟(在循环或程序完成后).
我不认为这种行为是正常的,在Windows打印下工作正常.该程序不使用线程.
哪里可能是问题?(Ubuntu 10.10 + NetBeans 6.9).
Why this condition is never true ? Both parts of the equation are integers, so there must be equality for index = 0, 10, 20, 30, 40. I am compiling this code using g++.
for(int index = 0; index < 50; index++){
if ( (int) (10 * ( 0.1 * index) == (int)(10 * ( int ) ( 0.1 * index ) ) ) )
{
std::cout << "equal";
}
}
Run Code Online (Sandbox Code Playgroud)
使用MSVS 2010编译器,这些问题不会发生......
0 0
1 0
2 0
3 …Run Code Online (Sandbox Code Playgroud)