c语言怎么实现四舍五入?
c语言怎么实现四舍五入?
日期:2018-12-02 16:23:53 人气:1
# incloud
int main(void)
{
float a ;
scanf(“%f”,&a);
a=(int)(a*1000+0.5)/1000.0;
printf (“%0.3f”,a);
return 0;
}
扩展资料:
其他方法实现四舍五入:
int myround(double indata,int precision,double * outdata){
long pre = 1,i;
for(i = 0; i <precision; i ++)pre = pre