标签:using cout http bit har string net efi for
https://blog.csdn.net/qq1013459920/article/details/81124577学习链接
例子:123.456 2(2表示小数第几个数后是循环开始)
//#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
char ch;
string s;
ll fm=1,fz=0,tt;
int k;
cin>>tt>>ch>>s>>k;
int len=s.size();
cout<<tt<<endl;
cout<<ch<<endl;
cout<<s<<endl;
cout<<k<<endl;
for(int i=len-k; i<len; i++)
{
fz=fz*10+s[i]-‘0‘;
}
for(int i=0; i<k; i++)
fm*=10;
fm--;
ll tf=1;
for(int i=0; i<len-k; i++)
{
fm*=10;
tf*=10;
tt=tt*10+s[i]-‘0‘;
}
ll ffm=tf*fm;
ll ffz=tt*fm+fz*tf;
ll ans=__gcd(ffz,ffm);
ffz/=ans;
ffm/=ans;
cout<<ffz<<"/"<<ffm<<endl;
return 0;
}
标签:using cout http bit har string net efi for
原文地址:https://www.cnblogs.com/hgangang/p/11629060.html