g++中出現0.00的情况

1 #include <stdio.h>
2
3 int main()
4 {
5 double x = 0;
6 printf("%.4f\n", -x / 5);
7 }

這段代碼最終的輸出結果的是-0.0000

這在某些題中會是個小trick應儘量避免。

即不要在printf表達式中出現負號,

或是另加特判處理。

原文地址:https://www.cnblogs.com/alex4814/p/2326735.html