22

四舍五入

https://ac.nowcoder.com/acm/problem/22006

我的小熊不见了写的也太长了
代码如下
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n,i,j=0;
cin>>n;
i=n%10;
if(i>=5)
{
j=10-i;
cout<<n+j;
}
else
cout<<n-i;
return 0;
}

全部评论
#include <stdio.h> #include <math.h> int main() { int a,b; scanf("%d",&a); a+=5; b=a-a%10; printf("%d\n",b); return 0; } 还可以更短</math.h></stdio.h>
点赞 回复 分享
发布于 2021-05-14 20:43

相关推荐

点赞 评论 收藏
分享
评论
14
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务