输入一个单精度浮点数,将其向零舍入到整数。说明:向零舍入的含义是,正数向下舍入,负数向上舍入。
#include<bits/stdc++.h>
using namespace std;
int main() {
double x;
cin>>x;
cout<<(long long)x;
}
或者在输入的时候就解决掉
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long a;
cin >> a;
cout << a << endl;
return 0;
}