#include <stdio.h> int main() { float a = 0.5; printf("%f,%0.2f\n",a,a); } 输出: 0.500000,0.50
输出都是自己控制的,默认是6位。如果觉得可以请采纳一下吧。
能整除的话就没有显示太多小数位的必要