#include <iostream> #include <cmath> using namespace std; int main(int argc, char** argv) { system("pause"); double x,y; int c[1][10]; int w; int k; do{ cout<<"x="; cin>>x; }while(x>=1||x<=0); c[0][0]=1;//a y=x; while(fabs(y-(int)y)>1e-10){ c[0][0]*=10;//a y=x*c[0][0];//a } c[0][1]=y;//b cout<<c[0][1]<<'/'<<c[0][0]<<endl; for(c[0][2]=c[0][1];c[0][2]>=1;c[0][2]--)//i if(c[0][1]%c[0][2]==0&&c[0][0]%c[0][2]==0){ c[0][3]=c[0][2]; break; } cout<<"最简分数为:"; cout<<c[0][1]/c[0][3]<<'/'<<c[0][0]/c[0][3]<<endl; }
标签:std,简分数,cout,10,int,include From: https://www.cnblogs.com/w6826301/p/17595616.html