奇怪的发现

猜猜下面两个程序会输出什么……

#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);
}

加一个很小的数就行了。

posted @ 2017-12-21 15:03  jz_597  阅读(86)  评论(0编辑  收藏  举报