题目 输入三个数 a表示分子,b表示分母,c表示小数后面几位数字; 输出小数
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,m,x;
cin >> a >> b >> c;
cout << a/b << ".";
while(c!=1)
{
a = (a%b)*10;
cout << a/b;
c--;
}
a = (a%b)*10;
x = a/b;
m = (a%b)*10/b;
if(m>5)
{
x++;
}
cout<<x;
return 0;
}
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有