题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
#include <stdio.h> int main() { float n=0.0f; scanf("%f",&n); int x=(int)n; float i=n-x; if(i>=0.5) { x=x+1; } else { x=x; } printf("%d\n",x); return 0; }
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
#include <stdio.h> int main() { float n=0.0f; scanf("%f",&n); int x=(int)n; float i=n-x; if(i>=0.5) { x=x+1; } else { x=x; } printf("%d\n",x); return 0; }
相关推荐