liaozichun @ 2024-08-09 15:07:24
#include<bits/stdc++.h>
using namespace std;
double a;
int main(){
cin>>a;
if(a > 0){
cout<<floor(a);
}
if(a < 0){
cout<<ceil(a);
}
return 0;
}
by Greeper @ 2024-08-09 15:17:06
@liaozichun 可以直接输入整形变量
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a;
cin>>a;
cout<<a;
return 0;
}
求关,谢谢
by liaozichun @ 2024-08-09 15:21:13
@Greeper 感谢大佬
by AqrDAD @ 2024-08-09 15:31:50
求关
解释一下你的代码为什么错:
改后的代码:
#include<bits/stdc++.h>
using namespace std;
double a;
int main(){
cin>>a;
if(a > 0){
cout<<(long long)floor(a);
}
if(a == 0) cout<<0;
if(a < 0){
cout<<(long long)ceil(a);
}
return 0;
}
by liaozichun @ 2024-08-09 15:49:58
@AqrDAD 感谢,关注了
by youthiscoming @ 2024-08-20 09:10:10
@liaozichun 十年oi一场空,不开long long见祖宗