需要舍弃浮点数的小数部分,因此我们直接把浮点数转成长整形就可以了 代码: C++复制#include<bits/stdc++.h> using namespace std; int main() { double x; cin>>x; cout<<(long long)x; }