Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将如何使用 printf() 函数打印浮点数,以使我只打印不为 0 的小数部分?例子:
1.0 -> 1 2.0 -> 2 1.5 -> 1.5 2.25 -> 2.25
等等
printf("%g\n",5.0); printf("%g\n",5.1);