美文网首页
《算法竞赛入门经典》CH1

《算法竞赛入门经典》CH1

作者: 洛朗不展傅立叶 | 来源:发表于2016-05-24 18:51 被阅读48次

    mac, Xcode
    一些无法得到理想结果的代码和实际输出样式

    1. no mistake
    printf(“%f\n", sqrt(-10));
    

    nan

    1. no mistake
    printf("%f\n", 1.0/0.0);
    

    inf

    #include <stdio.h>
    #include <math.h>
    int main()
    {   
        //no mistake
        printf("%f\n", 0.0/0.0);
    
        //no mistake, but warn
        //int isn't corresponded with double
        printf("%f\n", 0/0);
    
        //division by zero is undefined
        printf("%d\n", 0/0);
        return 0;
    }
    

    nan
    nan
    73823

    1. Two warn that division by zero is undefined
    printf("%d\n", 1/0);
    printf("%d\n", 0/0);
    

    1606416392

    相关文章

      网友评论

          本文标题:《算法竞赛入门经典》CH1

          本文链接:https://www.haomeiwen.com/subject/rmvzrttx.html