C++

Timeloop 发表于 6个月前 · 关联问题 分数化小数

参考了下面那位老哥的小数输出方法

非常坏的精度,恨来自广阔的东方

include

using namespace std;

int main(){

int a,b,c; int count=1; while(cin>>a>>b>>c&&(a!=0||b!=0||c!=0)){ cout<<"Case "<<count++<<": "<<a/b<<"."; int n=a%b; for(int i=0;i<c;i++){ n*=10; cout<<n/b; n%=b; } cout<<endl; } return 0;

}