《算法竞赛入门经典》CH1


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

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

nan

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

inf

#include 
#include 
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)