猜猜下面兩個程序會輸出什麼……
#include <cstdio>
using namespace std;
int main()
{
printf("%.0lf",0.5);
}
begin
write(0.5:0:0);
end.
對於我們來說,輸出是1
但是C++輸出是0,Pascal輸出是1!
但也不是沒有辦法!
#include <cstdio>
using namespace std;
int main()
{
printf("%.0lf",0.5+1e-10);
}
加一個很小的數就行了。