题解
2025-07-10 21:09:38
发布于:新疆
32阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
string x;
int n,m;
int a[10000005];
int main(){
cin>>n>>x>>m;
for(int i=2;i<x.size();i++){
a[i-1]=int(x[i])-'0';
}
a[0]=int(x[0])-'0';
if(a[m+1]>=5){
if(a[m]==9){
for(int i=m;i>=0;i--){
if(a[i]!=9&&i!=0){
a[i]++;
break;
}else if(i==0){
a[i]++;
break;
}
a[i]=0;
}
}else{
a[m]++;
}
}
if(m!=0){
cout<<a[0]<<".";
for(int i=1;i<=m;i++){
cout<<a[i];
}
}else{
cout<<a[0];
}
return 0;
}
这里空空如也
有帮助,赞一个