#include "stdio.h"
int main()
{
double x;
int y;
printf("请输入一个实数:\n");
scanf("%lf",&x);
y=(int)(x*1000);
if(y%10<=4)
y=y-y%10;
else
{
y=y+10;
y=y-y%10;
}
printf("该实数,四舍五入保留两位小后是%.2lf.\n",y*1.0/1000);
return 0;
}
运行结果: