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