OAOA @ 2017-08-07 21:40:04
//后面为输出
double test = 6 / 4;
cout << test<<endl; //1
printf("%f \n", test); //1.000000
cout << 6 / 4 << endl; //1
cout << (double)6 / 4 << endl; //1.5
printf("%f\n", 6 / 4); //0.000000
by 小粉兔 @ 2017-08-07 21:55:08
看第一句话,test那时候赋初值就是1了,因为6/4=1(整除)。正确姿势是double test=6/4.0
by 蒻得不行 @ 2017-08-09 21:23:27
索尼大法
by mtwoz @ 2017-08-25 18:46:53
索尼大法好