输入6.2356 欲其输出6.24(四舍五入)为什么总是输出0.00
#include<math.h>#include<stdio.h>
float fun(double f)
{ int a,y,z,w;
double x,b;
float c;
y=(int)floor(f);
x=f-y;
z=(int)(x*1000);
w=z%10;
a=(int)(x*100);
if(w>=5&&w<=9)
a+=1;
else a=a;
b=(double)a/100;
c=(float)(b+y);
return c;
}
main()
{
double h;
float v;
scanf("%f",&h);
v=fun(h);
printf("%.2f",v);
}