自己写了一个round四舍五入模板:
四舍五入代码模板:
#include <stdio.h>int round(double a)
{if(a-(int)(a)>=0.5)return (int)(a)+1;elsereturn (int)(a);
}int main()
{double a;int result;while(scanf("%lf",&a)!=EOF){result=round(a);printf("after round:%d\n",result);}return 0;
}
运行结果为: