题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
#include <stdio.h> #include <string.h> #include <math.h> int roundX(double x) { return (x >= 0) ? (int)(x + 0.5) : (int)(x - 0.5); } int main() { double n; scanf("%lf", &n); printf("%d", roundX(n)); }