Read post
#include <stdio.h>
#include <math.h>
#include<string.h>
int main(){
int n,j=0,a,b=1,t,i;
char o[20];
char p[20];
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%s",o);
for(t=0;t<=strlen(o)-2;t++)
p[t]=o[t+2];
for(t=0;t<=strlen(o);t++)
if (o[t]=='('){j=1;break;}
if(j==0){for (t=1;t<=(strlen(o)-2);t++)
b*=10;
sscanf(p,"%d",&a);
for (t=2;t<=b;t++)
{while ((a%t==0)&&(b%t==0))
{a=a/t; b=b/t;}
}
printf("%d/%d\n",a,b);
b=1;
}
if(j==1){for
}
while(1);
}
Reply
|