1、普通的printf输出打印
printf()函数的用例
float date=123.456;
printf("date=%.2f\n", date);//保留2位
printf("date=%.1f\n", date);//保留1位
输出
2、获取四舍五入后的数据
1、使用round函数
C ++ round()函数 (C++ round() function)
round() function is a library function of cmath header, it is used to round the given value that is nearest to the number with halfway cases rounded away from zero, it accepts a number and returns rounded value.
round()函数是cmath标头的