题解 | #取近似值#
取近似值
http://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
#include<stdio.h> int main() { float ipt; int k,opt; scanf("%f",&ipt); k = ipt*10; if (k%10 >= 5) opt = (int)ipt + 1; else opt = (int)ipt; printf("%d",opt);
}
取近似值
http://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
#include<stdio.h> int main() { float ipt; int k,opt; scanf("%f",&ipt); k = ipt*10; if (k%10 >= 5) opt = (int)ipt + 1; else opt = (int)ipt; printf("%d",opt);
}
相关推荐