C++暴力解法
#include<iostream> #include<math.h> using namespace std; int main() { float fl=0,temp=0; int shiwei=0,gewei=0; cin>>fl; temp=fl*10;//扩大10倍 shiwei=temp/10; //得到10位 gewei=temp-shiwei*10 ;//得到个位 if(gewei>=5) { shiwei=shiwei+1; } cout<<shiwei; }