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