b = (int)a;
#include<iostream> #include<iomanip> using namespace std; int main() { float a, b, c, d; cin >> a; b = (int) a; c = a - b; d = b*c; cout << fixed << setprecision(2) << d<<endl; }
如果能用字符串接输入的话建议用字符串接输入,然后通过 '.' 拆分再进行运算。